JavaScript
-
i hav three advertisements as flash movies(ad1.swf,ad2.swf,ad3.swf). i hav a combination of object and embed elements. i want these ads to reapted one after the other. each ads should stay for 1 minute. how can i rotate these ads in javascript? Thanks.
-
i hav three advertisements as flash movies(ad1.swf,ad2.swf,ad3.swf). i hav a combination of object and embed elements. i want these ads to reapted one after the other. each ads should stay for 1 minute. how can i rotate these ads in javascript? Thanks.
There are many solutions but here is one that might do the trick ...
// This section checks to see if the browser is IE4 or higher var RunningIE4 RunningIE4 = (msieversion() >=4); function msieversion() { var ua = window.navigator.userAgent var msie = ua.indexOf ( "MSIE " ) if ( msie > 0 ) // is Microsoft Internet Explorer; return version number return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) ) else return 0 // is other browser } var curBanner curBanner = 0 Bfiles = new Array() // image file names Btargets = new Array() // hyperlink targets Balt = new Array() // alt display Bfiles[0] = "ad1.swf" Btargets[0] = "http://www.the web address" Balt[0] = " description - can be blank" Bfiles[1] = "ad2.swf" Btargets[1] = "http://www.the web address" Balt[1] = " description - can be blank " Bfiles[2] = "ad3.swf" Btargets[2] = "http://www.the web address" Balt[2] = " description - can be blank" function startBanner() { window.setInterval("changeBanner();",60000); } function changeBanner() { if (RunningIE4 == true) { if (curBanner == (Bfiles.length -1)) { curBanner = 0; } else { curBanner++} Banner.src = Bfiles[curBanner] BannerTag.href = Btargets[curBanner] Banner.alt = Balt[curBanner] } }
and later in the web pageif (RunningIE4 == true) { document.write("<A NAME='BannerTag' HREF='" +Btargets[curBanner]+ "' TARGET='_new'><IMG NAME='Banner' BORDER=0 SRC='" +Bfiles[curBanner]+"' ALT='"+Balt[curBanner]+"' ></A>") } <NOSCRIPT> <A HREF="non-ie webpage.htm">for non MSIE browsers</A> </NOSCRIPT>
-
There are many solutions but here is one that might do the trick ...
// This section checks to see if the browser is IE4 or higher var RunningIE4 RunningIE4 = (msieversion() >=4); function msieversion() { var ua = window.navigator.userAgent var msie = ua.indexOf ( "MSIE " ) if ( msie > 0 ) // is Microsoft Internet Explorer; return version number return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) ) else return 0 // is other browser } var curBanner curBanner = 0 Bfiles = new Array() // image file names Btargets = new Array() // hyperlink targets Balt = new Array() // alt display Bfiles[0] = "ad1.swf" Btargets[0] = "http://www.the web address" Balt[0] = " description - can be blank" Bfiles[1] = "ad2.swf" Btargets[1] = "http://www.the web address" Balt[1] = " description - can be blank " Bfiles[2] = "ad3.swf" Btargets[2] = "http://www.the web address" Balt[2] = " description - can be blank" function startBanner() { window.setInterval("changeBanner();",60000); } function changeBanner() { if (RunningIE4 == true) { if (curBanner == (Bfiles.length -1)) { curBanner = 0; } else { curBanner++} Banner.src = Bfiles[curBanner] BannerTag.href = Btargets[curBanner] Banner.alt = Balt[curBanner] } }
and later in the web pageif (RunningIE4 == true) { document.write("<A NAME='BannerTag' HREF='" +Btargets[curBanner]+ "' TARGET='_new'><IMG NAME='Banner' BORDER=0 SRC='" +Bfiles[curBanner]+"' ALT='"+Balt[curBanner]+"' ></A>") } <NOSCRIPT> <A HREF="non-ie webpage.htm">for non MSIE browsers</A> </NOSCRIPT>
Thank you for your coopertion.