Developer forum

Forum » Development » Back to search result

Back to search result


Reply
I would like to make a "go back to search result" in the product template, used for search - and I am using the eCom search. Is there a special tag for this?
(I found one for ordinary search module) or could I please get some hints for writing it myself?

/Lise

Replies

 
Nicolai Høeg Pedersen
Reply
history.go(-1) would be the best...
 
Reply
Sometimes it's too easy! I was thinking about a lot of loooong server.request codes and that sort of stuff - but I think i'll try yours ;-)

/Lise
 
Jacob Bertelsen
Reply

Any thoughts on a Server.Request.PreviousUrl-tag, or something like that?

If a user likes to ctrl+click links, the javascript-method will not work, since it will only open a new window with

javascript:history.go(-1);

in the query string.

 
Jacob Bertelsen
Reply

Never mind. I will submit this as a feature request

 
Mikkel Ricky
Reply

Using document.referrer might be a better way to go

<div>
	<a id="back-to-search">Back to search</a>
	<script>(function() {
		var referrer = document.referrer,
		el = document.getElementById('back-to-search');
		if (referrer && el && referrer.indexOf('eComQuery') > -1) {
			// The referrer is (probably) a search url
			el.href = referrer;
		} else {
			el.parentNode.removeChild(el);
		}
	}());</script>
</div>

 

 
Jacob Bertelsen
Reply

Feature request case number is

93308

 

 

You must be logged in to post in the forum