Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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 重定向页面而不更改url_Javascript_Jquery - Fatal编程技术网

Javascript 重定向页面而不更改url

Javascript 重定向页面而不更改url,javascript,jquery,Javascript,Jquery,我在索引页上写了代码 window.location.replace(www.mysite.com/index2.html) 它重定向,但它也改变了明显的url 例如,当我运行www.mysite.com/index.html 它应该运行www.mysite.com/index2.html页面,浏览器地址应该显示www.mysite.com/index.html 我想在jquery或javascript中实现这一点。如果不欺骗浏览器的历史记录,就无法实现这一点。你可以在这里找到一个例子 否则,

我在索引页上写了代码

window.location.replace(www.mysite.com/index2.html)

它重定向,但它也改变了明显的url

例如,当我运行
www.mysite.com/index.html

它应该运行
www.mysite.com/index2.html
页面,浏览器地址应该显示
www.mysite.com/index.html


我想在jquery或javascript中实现这一点。

如果不欺骗浏览器的历史记录,就无法实现这一点。你可以在这里找到一个例子

否则,您可以使用框架在
index.html


请注意,并非所有浏览器都支持
history.pushState()

我知道这可以通过经典asp页面中的server.transfer来完成。我很好奇用jquery来做这件事。