How to do a Redirect to an HTTP POST Request with Javascript?I summarized 5 ways to redirect URL.(The purpose of below script is to perform a local redirect using Javascript)
1,
<script language=”javascript” type=”text/javascript”> window.location.href=”login.jsp?backurl=”+window.location.href; </script>
2,
<script language=”javascript”> alert(”back”); window.history.back(-1); </script>
3,
<script language=”javascript”> window.navigate(”top.jsp”); </script>
4,
<script language=”JavaScript”> self.location=”top.htm”; </script>
5,
<script language=”javascript”> alert(”Access Violation”); top.location=”error.jsp”; </script>
Just be aware of bug 223 in Internet Explorer 6 (and below)
http://webbugtrack.blogspot.com/2007/09/bug-223-magical-http-get-requests-in.html
You will find that in certain cases setting the .href from javascript will NOT work in IE.
Please tell me redirection, if use redirection code
It effect Google search engine ?
It has helped me.
Thanks a lot.
I using 1′st model. Its work, but I can not guarantee google will happy
I’m using number 4.
self.location=”top.htm”;
Works in IE6 and FF3.
Thanx for sharing.
this is good. thanks a lot.
[...] 5 ways to redirect URL with Javascript [...]
I tried option 4 will implementing a solution for CSRF and it works
in IE 7.0 , FF 3.5 and Opera 10.10
Thanks
Raj
Simple implementation of CSRF protection in JSPs:
self.location=”Login.jsp”;
self.location=”Login.jsp”;
Thx a lot, It has helped me.
thankssssss
very nice, didn’t know there were so many ways
thanks ..useful info..easy to find ..came up at top in google search..
location.replace(‘/’);
This is what I use, this will replace url in browser history, so browser back button wont result in a loop
[script language=”javascript”]
location.replace(‘www.regexhacks.com/’);
[/script]
This is what I use, this will replace url in browser history, so browser back button wont result in a loop
Good idea for a post. Very useful.
@Rajeev
Interesting. They need to add that one to the list.
Thank you so much for the simple yet powerful way of navigation. It solved my purpose tentatively.
Great helpfull collection, please also include that way
cheers
Great helpfull collection, please also include that way:
//*sorry – no script in comments*//
setTimeout(‘Redirect()’,3000);
function Redirect()
{
location.href = ‘hxxp://forfruits.pl’;
}
//end//
cheers
Thank you very much!!
I don’t know which one to use for my website.
hello thеre and thank уou for youг infoгmatіon
I’ve certainly picked up something new from right here. I did however expertise several technical issues using this website, as I experienced to reload the website many times previous to I could get it to load properly. I had been wondering if your web host is OK? Not that I am complaining, but slow loading instances times will often affect your placement in google and can damage your quality score if advertising and marketing with Adwords. Anyway I am adding this RSS to my email and could look out for much more of your respective fascinating content. Make sure you update this again very soon.
Thank you
Thanks for this information but I have a little question
What’s the difference between these methods ???
I found the codes i need. thanks for the post