0

I am trying to create an SOS page in which i am changing the links on the page after the button click. My problem here is that the links get changed but they get appended to the current pages URL.

My links do contain http:// (My reputation is less than 10 here)

Eg.

Originall link -- "htp://xyz.com?login_type=encrypted&login=&password="
Required link -- "htp://xyz.com?login_type=encrypted&loginxxx=&password=yyy"
Actual link that I am getting -- "htp://currentpageURL.com"htp://xyz.com?login_type=encrypted&login=&password=""

Here is the js I am using

function handleClick()
{

    var uid, pwd;
    uid = $("#uid").val();              
    pwd = $("#pwd").val();  
    if(uid != "" && pwd != "")
    {    
        $("#links").show();
        $("#login").hide();
        $('a').each(function () {
            var href = $(this).attr("href");
            $(this).attr("href", href.replace("login=", "login=" + uid).replace("password=", "password=" + pwd));
        });
    }
    else { alert("Please enter valid credentials"); }       
}
blue112
  • 52,634
  • 3
  • 45
  • 54
user2285398
  • 1
  • 1
  • 1
  • 3

1 Answers1

0

You could find the "last part" of the script using the attached link and then just add the "login=" and "password="" to then end? See: this.href vs $(this).attr('href')

Community
  • 1
  • 1
Anthony Horne
  • 2,522
  • 2
  • 29
  • 51