网页找不到javascript错误 [英] Webpage not found javascript error
问题描述
我对JavaScript非常陌生,当我遇到这个错误时,我的web浏览器找不到html文档,当位置变量位于< script< / script
tags
I am very new to javascript and was practicing when i came accross this error where my web browser can't find the html document when the location variable is inside the <script</script
tags
<script>
<!--
var location = "Syrdsase va";
var name = "bob sixlet";
var age = 14;
document.write(name + ", " + age + location);
//-->
</script>
推荐答案
There is a location
object which when assigned to, changes the location of the page:
location = 'http://www.google.com'; // goes to Google homepage
通常,为避免混淆,通常使用 window.location
,但由于 window
仅仅是全局对象,所以重新分配 location >将使页面转到字符串值的URL。
Usually, to avoid confusion, it is usually referred to using window.location
, but since window
is simply the global object, reassigning location
will make the page go to the URL that is the value of the string.
要解决该问题,只需重命名该变量:
To solve the issue, simply rename the variable:
var myLocation = "Syrdsase va";
var name = "bob sixlet";
var age = 14;
document.write(name + ", " + age + myLocation);
这篇关于网页找不到javascript错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!