Alex Rivera | Logout

What is a good solution for cross browser javascript redirect with history?

Asked 2009-07-23T19:21:52.523
13

I am currently fighting Google Chrome on the following action:

location.href = url

location.replace(url)

document.location = url

window.navigate(url) // doesn't work in Chrome/Firefox

location.assign(url)

window.open(url, '_self')

window.location.href = url

I have tried all, and neither will add a history entry. Is there a way in Google Chrome to do a javascript redirect WITH history?

Thanks.


Explanation We have a table of items, when clicking on the row, I want the page to navigate to a specified URL, if anyone has a good solution to this other than using the onclick=send method we are using now, please let me know.


Update It appears that Stackoverflow its-self has this exact same issue. In the main view, click on one of the first 3 columns in the question list (# answers, etc..), then click the back button, it will take you back 2 pages.

Edit
Report

1 Answer

0

What about "clicking" a link with JS?

<a href="/url.html" id="clickme">blah blah</a>
<script type="text/javascript">
$(document).ready(function() {
    $('#clickme').click();
});
</script>

I'm not sure if this work, but it should mimic a user clicking the link.

answered 2009-07-25T05:30:18.293

Your Answer