Multiple slideshows on the same page

陌路散爱 提交于 2019-12-11 16:53:08

问题


I am having trouble running more then one slideshow on one page. I am trying to make due with the code i was given (which i know is out dated). My first problem was the use of multiple functions with the same name, i solved that problem by embedding the functions into other functions to distinguish between them (ex: show1() show2()). Here is what i have so far, im not sure what is the problem now as it could be multiple things and my lack of javascript knowledge. Any help would be great thank you!

<!-- The following script is for the rotating images for the banner ad in right column            -->
<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -

if (document.images) {
ads = new Array(5);
ads[0] = "./images/okuma.jpg";
ads[1] = "./images/schlumberger.gif";
ads[2] = "./images/uesystems_logo.jpg";
ads[3] = "./images/brady.jpg";
ads[4] = "./images/ats.png";
}

newplace = new Array(5);
newplace[0] = "http://www.okuma.com/home.html" 
newplace[1] = "http://www.slb.com/"
newplace[2] = "http://www.uesystems.com/"
newplace[3] = "http://www.bradyid.com/bradyid/cms/contentView.do/6974/Visual-     Workplace.html"
newplace[4] = "http://www.advancedtech.com/"


var timer = null
var counter = 0

function banner() {
        timer=setTimeout("ban()", 6000);
        counter++;
        if (counter >= 5)
        counter = 0;
        document.bannerad1.src = ads[counter];
}

function show1(){
function gothere() {
        counter2 = counter;
        window.open(newplace[counter2]);
}
}
// - End of JavaScript - -->

</script>

<!-- The following script is for the rotating images for the banner ad in right column(2)  -->
<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -

if (document.images) {
ads = new Array(4);
ads[0] = "./marcon/images/arms_reliability_logo.jpg";
ads[1] = "./marcon/images/brunson_logo.jpg";
ads[2] = "./marcon/images/ctc_logo.jpg";
ads[3] = "./marcon/images/descase_logo.jpg";
}

newplace = new Array(4);
newplace[0] = "http://www.globalreliability.com/home" 
newplace[1] = "http://www.brunson.us"
newplace[2] = "http://www.ctconline.com/_home.aspx"
newplace[3] = "http://www.des-case.com"



var timer = null
var counter = 0

function banner() {
        timer=setTimeout("banner()", 6000);
        counter++;
        if (counter >= 4)
        counter = 0;
        document.bannerad2.src = ads[counter];
}
function show2(){
function gothere() {
        counter2 = counter;
        window.open(newplace[counter2]);
}
}
// - End of JavaScript - -->

</script>

and

    <p align="center"><font size="2"><b>Companies Supporting<br />R&M Research:</b><br  />     (click logo for company info)</font></p>
        <p align="center"><a href="javascript:show1()"><IMG   SRC="./images/schlumberger.gif" WIDTH="180" HIGHT="200" BORDER="0" NAME="bannerad1"></a>
</p>
       <br />

            <hr noshade="noshade" size="0" color="#4c617e" />
 <br />

        <p align="center"><font size="1"><b>Thank you to the following for<br />their MARCON '12 support</b><br />(click logo for company info)</font></p>
        <p align="center"><a href="javascript:show2()"><IMG  SRC="./marcon/images/arms_reliability_logo.jpg" WIDTH="180" HIGHT="200" BORDER="0"   NAME="bannerad2"></a>


回答1:


Take a look at this working example. Hopefully you can pick up a little javascript knowledge by studying it a bit.

http://jsfiddle.net/RRjGP/3/



来源:https://stackoverflow.com/questions/11479234/multiple-slideshows-on-the-same-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!