2
votes

let's say I am on this page:

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

my index.html page has a link like this:

<a href='help.html'>help</a> 

If I click on it the browser takes me there and my url changes it to this:

http://localhost:4444/help.html

But what I wish it had happened is that I would not lose the 'search query' so that I would be taken here:

http://localhost:4444/help.html?user=test

Is there an easy way to achieve this ? possibly without javascript..

2
One algorithm can be to save a copy of the URL query in the cookies and whenever a new page is requested from the server, send a 301 message (permanently moved) to the new query string from cookie.AlexStack
If you don't want to do it with JavaScript then you're going to have to do it with server-side code. Plain HTML doesn't have anything for this.David
@David Can you elaborate your answer ? are you sure plain html has nothing for this ?Zo72
@Zo72: Well, to my knowledge it doesn't. But if you discover otherwise then by all means share it, I'd love to learn something new.David

2 Answers

1
votes

You can read also document.referrer from the visited page

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

and split on '?' to get the search expression.

1
votes

No, there is no easy solution for this problem. You need to use javascript and the location object.

you need to ensure that you enrich the a urls with the search part

(and others e.g. hash if required)