How to get binding from url in IE / Safari?

I have a webpage that uses bindings to navigate menu categories. Basically, when a user clicks on a link, he is redirected to the current page, where I parse the anchor from the URL using Javascript to determine which page to display. This works fine in every browser except IE8 (and below) and Safari, where the anchor does not appear at all in the URL, so it cannot be parsed.

Is there any way to link to bindings in these browsers?

Here is the code:

HTML

<a href="../menu#page1">Page 1</a> 

JavaScript:

 var url = window.location.href; var loc = url.substring(url.indexOf("#")+1); 

EDIT: code added

+4
source share
1 answer

You can use a hidden field with simillar value for href ancher tag.

 <a href="../blah-blah/my-page.html"> <input type="hidden" name="link-url" value="="../blah-blah/my-page.html"/> 

The value of your link URL will appear in the query bar as www.some-site.html?link-url=../blah-blah/my-site.html somthing like this. Now you can use your javascript logic to extrapolate this value.

+2
source

All Articles