Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.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_Html_Hyperlink - Fatal编程技术网

Javascript 不带';";“失去”;url搜索部分。如何?

Javascript 不带';";“失去”;url搜索部分。如何?,javascript,html,hyperlink,Javascript,Html,Hyperlink,假设我在这一页: http://localhost:4444/index.html?user=test my index.html页面有如下链接: <a href='help.html'>help</a> 但我希望发生的是,我不会丢失“搜索查询” 所以我会被带到这里: http://localhost:4444/help.html?user=test 有没有一个简单的方法来实现这一点? 可能没有javascript。您也可以从访问的页面中读取document.re

假设我在这一页:

http://localhost:4444/index.html?user=test
my index.html页面有如下链接:

<a href='help.html'>help</a> 
但我希望发生的是,我不会丢失“搜索查询” 所以我会被带到这里:

http://localhost:4444/help.html?user=test
有没有一个简单的方法来实现这一点?
可能没有javascript。

您也可以从访问的页面中读取document.referer

//localhost:4444/index.html?user=test

并在“?”上拆分以获得搜索表达式。

否,此问题没有简单的解决方案。 您需要使用javascript和location对象

您需要确保使用搜索部分丰富a URL


(以及其他算法,如需要时使用哈希)

一种算法是在cookie中保存URL查询的副本,每当服务器请求新页面时,从cookie向新查询字符串发送301消息(永久移动)。如果不想使用JavaScript,则必须使用服务器端代码。纯HTML对此没有任何帮助。@David你能详细说明你的答案吗?你确定纯html对此毫无用处吗?@Zo72:据我所知,它没有。但是如果你发现了其他的东西,那就一定要分享,我很想学习一些新的东西。
//localhost:4444/index.html?user=test