Kode Plex
Kode Plex

Reputation: 47

jquery redirect issues

I am having problems in redirecting page with jquery. I have a variable url which contains localhost/abc#123. When i write document.location.href = url;, the page redirects to localhost/abc leaving #123. How to resolve this issue

Upvotes: 1

Views: 180

Answers (1)

Anirudha Gupta
Anirudha Gupta

Reputation: 9289

var url = "http://bing.com/refresh/test.html#123";

document.location.href=url

it's work fine for me in my firefox. do you have tried to debug what happen on your side. I have test this code in IE8 + firefox + chrome. I hope it's will work fine for you.

if this code doesn't work on your side then try

window.location.replace(url)

as your comment it's look like you have used Anchor so tried this one.

$("#myanchor").click(function(e){
e.preventDefault();

// redirect code here
});

Upvotes: 3

Related Questions