CBaZ Posted August 27, 2008 Share Posted August 27, 2008 <script language=javascript>function loadsource() { var defaultPage = "default.html (Enter the filename you want as your default here)"; var query = window.location.search.substring(1); var pos = query.indexOf('='); if (pos > 0) { var frameSource = query.substring(pos+1); window.frames["bob"].location = frameSource; } else { window.frames["bob"].location = defaultPage; } } </script> that would be in the head section then the body section <body onLoad="loadsource()"><iframe name="bob" width="621" height="447" horizonalscrolling="yes" frameborder="0" ></iframe> and finally this is how I would call the link via the url box http://mysite.com/index.html?fs=finalcontent.html I was wondering if there is anyway that I can do the same thing just in a different way. the reason why i ask is because my iframe has an onload function as well and its not working in conjunction with the above. any ideas? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted August 27, 2008 Share Posted August 27, 2008 Please your code. What is the iframe's onload function? Why don't you move the body's onload function to the iframe's? Quote Link to comment Share on other sites More sharing options...
CBaZ Posted August 27, 2008 Author Share Posted August 27, 2008 <script type="text/javascript"> adds=[ // url,alt,image ["url,"alt,"image"], "url,"alt","image"] ] count=0 count = Math.floor(Math.random()*adds.length); onload=function test() { test2(); oLink=document.getElementById("mylink") oImg=document.getElementById("myimg") oLink.href=adds[count][0] oImg.alt=adds[count][1] oImg.src=adds[count][2] count++ if(count==adds.length){ count=0 } setTimeout("test()",48000) } </script> there is 2 of these for different size banners. now i've tryed puttin the body onload into the iframe and that just brings up object expected error with the URL http://mysite.com/index.php?fs= there should be something after = which is typed in the url but it won't direct. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted August 27, 2008 Share Posted August 27, 2008 I don't understand any of this. ??? Even your JavaScript code that you posted makes little sense to me. What is with the onload=function() thing? Can you post all the HTML with the JavaScript you use? Quote Link to comment Share on other sites More sharing options...
CBaZ Posted August 27, 2008 Author Share Posted August 27, 2008 the above is the banner rotation script. different ads. the onload=function test() { test2(); test() is the first banner test2() is the 2nd banner. now the function loadsource which is the external link to iframe is not working in conjunction with the banner function test(1) and test (2) so we have the test 1 function above here is the 2nd function <script type="text/javascript"> adds2=[ // txt, url,alt,image ] ["url","alt","image"], // banner url, banner alt, banner image ["url","alt","image"] // this one is last entry so no comma count2 = Math.floor(Math.random()*adds2.length); function test2(){ oLink2=document.getElementById("mylink2") oImg2=document.getElementById("myimg2") oLink2.href=adds2[count2][0] oImg2.alt=adds2[count2][1] oImg2.src=adds2[count2][2] var cx2 = 0; count2 = 0; while (cx2 == count2) { count2 = Math.floor(Math.random()*adds2.length); } cx2 = count2; } </script> <center><a id="mylink2" href="#null" target="_blank" onMouseOver="window.status='Our Sponsors Help Save Money, Please Support.'; return true"><img id="myimg2" src="" alt="" style="width:468px;height:60px" border="0"></a></center> this is what i forgot to post earlier it ties it all together to print out the banner ad. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted August 27, 2008 Share Posted August 27, 2008 Could you post the rest of the JavaScript and the iframe too? As for the banner, here's a better code: <script> var banner = []; banner[banner.length] = ["link", "alt"]; var random = Math.floor(Math.random() * banner.length + 1); var teh_image = document.getElementById("myimg2"), teh_banner = banner[random]; teh_image.src = teh_banner[0]; teh_image.alt = teh_banner[1]; </script> I'm still unsure what the iframe does, but if you can tell me, I can help more. Quote Link to comment Share on other sites More sharing options...
CBaZ Posted August 27, 2008 Author Share Posted August 27, 2008 this ad script doesnt need an onload maybe it will work then. how can i add more then one banner to this and sizes? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted August 27, 2008 Share Posted August 27, 2008 this ad script doesnt need an onload maybe it will work then. how can i add more then one banner to this and sizes? <script> var banner = []; banner[banner.length] = ["link", "width", "height", "alt"]; var random = Math.floor(Math.random() * banner.length + 1); var teh_image = document.getElementById("myimg2"), teh_banner = banner[random]; teh_image.src = teh_banner[0]; teh_image.width = teh_banner[1]; teh_image.height = teh_banner[2]; teh_image.alt = teh_banner[3]; </script> Use that. To add more, just copy: banner[banner.length] = ["link", "width", "height", "alt"]; and paste it under the previous one and edit the stuff. Quote Link to comment Share on other sites More sharing options...
CBaZ Posted August 27, 2008 Author Share Posted August 27, 2008 this doesn't seem to work afterall and there is no url for a user to click. and it creates errors. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted August 27, 2008 Share Posted August 27, 2008 this doesn't seem to work afterall and there is no url for a user to click. and it creates errors. What errors? Quote Link to comment Share on other sites More sharing options...
CBaZ Posted August 27, 2008 Author Share Posted August 27, 2008 no image it just stays blank for some reason Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted August 27, 2008 Share Posted August 27, 2008 Mind showing me the entire JavaScript and HTML you have there? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.