Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 自动加载新页面,仅访问正文中的元素_Javascript_Load - Fatal编程技术网

Javascript 自动加载新页面,仅访问正文中的元素

Javascript 自动加载新页面,仅访问正文中的元素,javascript,load,Javascript,Load,当我只能访问页面主体而不能访问页首时,有没有办法在没有用户交互的情况下加载新的不同页面 例如,以下代码失败: <a href="javascript:function(){window.open('http://www.google.com','_self')}();">open google home page</a> (我希望在当前页面加载后立即加载www.google.com,而无需任何用户点击其任何一个元素) 请不要使用jQuery。删除函数()。应该是:

当我只能访问页面主体而不能访问页首时,有没有办法在没有用户交互的情况下加载新的不同页面

例如,以下代码失败:

<a href="javascript:function(){window.open('http://www.google.com','_self')}();">open google home page</a>

(我希望在当前页面加载后立即加载www.google.com,而无需任何用户点击其任何一个元素)

请不要使用jQuery。

删除
函数()。应该是:


<a href="http://www.google.com" rel="autoopen" onclick="return false;">open google home page</a>


对于(var i=0;i
删除
函数()。应该是:


<a href="http://www.google.com" rel="autoopen" onclick="return false;">open google home page</a>


对于(var i=0;i
只需将脚本元素插入页面,如下所示:

<script type="text/javascript">
  window.location.href = "http://www.google.com/"
</script>

window.location.href=”http://www.google.com/"

只需将脚本元素插入页面,如下所示:

<script type="text/javascript">
  window.location.href = "http://www.google.com/"
</script>

window.location.href=”http://www.google.com/"

就在关闭车身标签前放置

<script>
 location.href = "http://www.google.com";
</script>

location.href=”http://www.google.com";

就在关闭车身标签前放置

<script>
 location.href = "http://www.google.com";
</script>

location.href=”http://www.google.com";