开发者

Redirecting to a page in a domain using greasemonkey

开发者 https://www.devze.com 2023-02-19 04:51 出处:网络
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

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:

  1. Add an exclude rule which will cause your script to be not be executed on the access.aspx page.

    @exclude http://www.domain.com/access.aspx.

  2. 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); 
    }
    
0

精彩评论

暂无评论...
验证码 换一张
取 消