我正在尝试在 Windows Application Js App 中按顺序显示图像。脚本如下。这在记事本中有效,但在“.net”中无效。我在主文件夹中添加了单独的文件“scrolling.js”,下面的代码就在其中。错误指向 rotator.src 。我错过了什么吗?
<body>
<!-- The content that will be loaded and displayed. -->
<div class="fragment homepage">
<header aria-label="Header content" role="banner">
<button class="win-backbutton" aria-label="Back" disabled type="button"></button>
<h1 class="titlearea win-type-ellipsis">
<span class="pagetitle">Welcome to AppTweenMax!</span>
</h1>
</header>
<section aria-label="Main content" role="main">
<div id="demo">Content goes here.</div>
<img src="imagesroll/1.png" alt="rotating image" width="640" height="960" id="rotator">
</section>
</div>
<script type="text/javascript">
(function () {
var rotator = document.getElementById('rotator'); // change to match image ID
var imageDir = 'imagesroll/'; // change to match images folder
var delayInSeconds = 2; // set number of seconds delay
// list image names
var images = ['2.png', '3.png', '4.png', '5.png', '6.png', '7.png'];
// don't change below this line
var num = 0;
var changeImage = function () {
var len = images.length;
var src = imageDir + images[num++];
document.getElementById('rotator').src = "" + src;
rotator.src = src;
if (num == len) {
num = 0;
}
};
setInterval(changeImage, delayInSeconds * 1000);
})();
</script>
</body>