同一页面上有多个幻灯片

时间:2012-07-13 22:35:52

标签: javascript slideshow

我无法在一个页面上运行多个幻灯片。我正在尝试使用我给出的代码(我知道它已过时)。我的第一个问题是使用同名的多个函数,我通过将函数嵌入其他函数来区分它们来解决这个问题(例如:show1()show2())。这是我到目前为止,我不知道现在的问题是什么,因为它可能是多个事情和我缺乏JavaScript知识。任何帮助都会非常感谢你!

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

1 个答案:

答案 0 :(得分:0)

看看这个工作示例。希望你能通过研究一下来获得一些小的javascript知识。

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