![](/img/trans.png)
[英]javascript not executing instead it shows the function name in the address bar
[英]Why is the file name getting replace by a JavaScript function in the address bar?
本地html文件,可以說其路徑為/path/to/file.html
。 開始時有以下內容。
<html>
<head>
<link rel="shortcut icon" href="logo.ico"/>
<LINK href="1.css" rel="stylesheet" type="text/css" />
<script src="1.js" type="text/javascript"> </script>
</head>
<body class = "body_background">
.
.
.
嘗試使用瀏覽器的完整路徑在瀏覽器中打開它時:
文件名及其擴展名( file.html
)被JavaScript函數替換。
即
file:///path/to/file.html
更改為以下內容:具有擴展名的文件名將替換為1.js
的函數location
。
file:/// path / to / function location(){ ...
JavaScript文件的開頭是這樣的:
if(window.addEventListener) {
window.addEventListener('load', location, false);
}
else if (window.attachEvent) window.attachEvent('onload', location);
這是在FireFox
和Safari
上發生的,而不是通過Chrome
發生的。
在Chrome
,頁面會正確顯示。
這個問題是給朋友的。
在某些JS實現中, location
是保留字,例如document.location
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.