gpt4 book ai didi

javascript - 在 Javascript 中加载正文

转载 作者:行者123 更新时间:2023-12-04 11:23:12 25 4
gpt4 key购买 nike

我在 asp.net 中写过一个 JS。我已经从正文 onload 中调用了它,但是在我放置调试器的地方没有调用 JS。这可能是什么原因?我正在使用 dotnetnuke 开发网站。

我写的JS在语法和逻辑上都是正确的。

<script type="text/javascript">

var displayTime, speed, wait, banner1, banner2, link1, link2, bannerIndex, bannerLocations, bannerURLs;

function initVar() {
debugger;

displayTime = 10; // The amount of time each banner will be displayed in seconds.
speed = 5; // The speed at which the banners is moved (1 - 10, anything above 5 is not recommended).
wait = true;

banner1 = document.getElementById("banner1");
banner2 = document.getElementById("banner2");
//link1 = document.getElementById("link1");
//link2 = document.getElementById("link2");

//banner1 = document.getElementById("banner1");
//banner2 = document.getElementById("banner2");

banner1.style.left = 0;
banner2.style.left = 500;

bannerIndex = 1;

/* Important: In order for this script to work properly, please make sure that the banner graphic and the
URL associated with it have the same index in both, the bannerLocations and bannerURLs arrays.
Duplicate URLs are permitted. */

// Enter the location of the banner graphics in the array below.
//bannerLocations = new Array("internet-lg.gif","jupiterweb.gif","jupitermedia.gif");

bannerLocations = new Array("image00.jpg", "image01.jpg", "image02.jpg", "admin_ban.bmp");

// Enter the URL's to which the banners will link to in the array below.
bannerURLs = new Array("http://www.internet.com","http://www.jupiterweb.com","http://www.jupitermedia.com");
}

function moveBanner() {
//debugger;
if(!wait){
banner1.style.left = parseInt(banner1.style.left) - (speed * 5);
banner2.style.left = parseInt(banner2.style.left) - (speed * 5);
if(parseInt(banner1.style.left) <= -500){
banner1.style.left = 500;
bannerIndex = (bannerIndex < (bannerLocations.length - 1)) ? ++bannerIndex :0;
banner1.src = bannerLocations[bannerIndex];
//link1.href = bannerURLs[bannerIndex];
wait = true;
}
if(parseInt(banner2.style.left) <= -500){
banner2.style.left = 500;
bannerIndex = (bannerIndex < (bannerLocations.length - 1)) ? ++bannerIndex :0;
banner2.src = bannerLocations[bannerIndex];
//link2.href = bannerURLs[bannerIndex];
wait = true;
}

setTimeout("moveBanner()",100);
} else {
wait = false;
setTimeout("moveBanner()", displayTime * 1000);
}
}

</script>

在 JS 中注册

<body onload="initVar(); moveBanner();">

</body>

最佳答案

我运行了你的代码。这两种方法都在我无需对发布的代码进行任何修改的情况下执行。是否可能有一些其他代码正在覆盖 onload 方法?

关于javascript - 在 Javascript 中加载正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1952023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com