Jump to content

external link to iframe


CBaZ

Recommended Posts

<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?

 

Link to comment
Share on other sites

<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.

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.