为什么文件名会被地址栏中的JavaScript函数替换?
本地html文件表示其路径为为什么文件名会被地址栏中的JavaScript函数替换?,javascript,html,browser,web,Javascript,Html,Browser,Web,本地html文件表示其路径为/path/to/file.html。在开始时有以下内容 <html> <head> <link rel="shortcut icon" href="logo.ico"/> <LINK href="1.css" rel="stylesheet" type="text/css" /> <script
/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">
.
.
.
这种情况发生在FireFox和Safari上,而不是Chrome上
在Chrome
上,页面会正确显示
这个问题是给朋友的。
location
在一些JS实现中是保留字,如document.location
请参阅:@Diodeus这是一个函数!
location
不是一个保留的javascript对象/术语吗?它有自己的javascript实现,没有这个限制。它不是一个保留字。它是一个属性名,如window.location
中所示。
if(window.addEventListener) {
window.addEventListener('load', location, false);
}
else if (window.attachEvent) window.attachEvent('onload', location);