同一页面上有多个幻灯片

2022-04-17 00:00:00 javascript slideshow

在一页上运行多个幻灯片时遇到问题。我正在努力使我得到的代码到期(我知道它是过时的)。我的第一个问题是使用多个同名的函数,我通过将这些函数嵌入到其他函数中以区分它们来解决这个问题(例如:show1()show2())。这是我到目前为止所得到的,我不确定现在的问题是什么,因为它可能是多方面的,以及我缺乏对Java脚本的了解。任何帮助都是非常好的,谢谢!

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

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


解决方案

查看此工作示例。希望您可以通过稍微学习一下它来获得一点Java脚本知识。

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

相关文章