Basically i want to access site http://www.domain.com
what i want开发者_如何学Go to do is that upon logging in, it should directly take me to
http://www.domain.com/access.aspx
But I have very little knowledge of java script, so far i made it but its continuely redirecting in in a loop like
http://www.domain.com/access.aspx/access.aspx/access.aspx/access.aspx/access.aspx/access.aspx
Why is it redirecting again and again, i just want it to redirect it once.
This is my existing code
var loc = window.location.href; var a = loc +"access.aspx"; window.open(a);
I am using a separate script for logging in, and separate for redirecting.
You don't seem to be checking if redirection is required so I suspect that your redirection logic is being applied even when you're already on the page you want to be on. Consider one of the following:
Add an
exclude
rule which will cause your script to be not be executed on theaccess.aspx
page.@exclude http://www.domain.com/access.aspx
.Check before you redirect, something like
var loc = window.location.href; if(loc != 'http://www.domain.com/access.aspx'){ var a = loc +"access.aspx"; window.open(a); }
精彩评论