文件无法在 Chrome 或 Firefox 中打开,网址中的文件名更改为"0"



我尝试在Google和此处搜索"浏览器中的文件名更改为0",但无处可寻。这是一个简单的文件,突然停止打开。我什至无法抓住检查员对其进行故障排除。撤消/重做历史记录丢失了,这将无济于事。我猜这是一个简单的错误,但我以前从未见过。

<!doctype html>
  <html lang="en">
  <head>
    <title>JS Animated Navigation Test</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script>
        <!--
        var location = 0; 
        var bar = document.getElementById("bar1");
        function myMove()
        {
        // if (id != 0) clearInterval(id);
        location = -144; 
        // if (location != -144) return; // don't execute onmouseover while previous onmouseover is still running. 
        id = setInterval(move, 1);
        }  
        function move() 
        {
            location++; 
            bar.style.left = location + 'px'; 
            if (location == 300)
            {
                clearInterval(id);    
                id = setInterval(moveback, 1); 
            }  
        }
        function moveback()
        {
            location--; 
            bar.style.left = location + 'px';    
            if (location == -144)  
            {
                clearInterval(id);    
                // id = setInterval(move, 1); 
            }  
        }
    -->
    </script>
    <style>
    #container
    {
        width: 600px;
        height: 100px;
        position: relative;
        background: white;
    }
    #bar1
    {
        width: 150px;
        height: 30px;   
        position: absolute;
        left: -144px; 
        background-color: white;
    }
    </style>
</head>
<body>
<p>
<button onclick="myMove()">Click Me</button>
</p>
<div id ="container">
<div id ="animate"><img src="imageGalleryBar.png" alt="Image Gallery" width="150" height="30" id="bar1" onmouseover="myMove()" /></div>
</div>
</body>
</html>

谢谢

您不能使用变量名称 location,因为它是一个保留的单词;您实际在做的是将window.location变量设置为0

重命名,或将其放在命名空间或对象中。

相关内容

最新更新