This is the code of login.html :
<ul>
<li class="introduction">
<a href="introduction.html">
<span class="icon"></span>
Introduction
</a>
</li>
<li class="login active">
<a href="#">
<span class="login"></span>
Login
</a>
</li>
</ul>
An external link will first take to the current page (login) with some query parameters I want to keep . If the user clicks the first link introduction
, the introduction.html will be loaded. However, all the query parameter of the previous page (login) are lost.
Is there anyway I can do this page load while keeping the query parameters? Either using HTML or Javascript.
Many thanks.
The part of the URL you're interested into is called search .
You may link to another page with the same parameters using
<a onclick="window.location='someotherpage'+window.location.search;">Login</a>
Automatically append your current params to any links you deem worthy via a rel=""
attribute on <a>
tags (using jQuery):
<a href="introduction.html" rel="keep-params">Link</a>
// all <a> tags containing a certain rel=""
$("a[rel~='keep-params']").click(function(e) {
e.preventDefault();
var params = window.location.search,
dest = $(this).attr('href') + params;
// in my experience, a short timeout has helped overcome browser bugs
window.setTimeout(function() {
window.location.href = dest;
}, 100);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.