[removed] sending custom parameters with window.open() but its not working

前端 未结 5 1606
一整个雨季
一整个雨季 2021-02-14 05:58




         


        
5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-14 06:17

    if you want to pass POST variables, you have to use a HTML Form:

    or:

    if you want to pass GET variables in an URL, write them without single-quotes:

    http://yourdomain.com/login?cid=username&pwd=password
    

    here's how to create the string above with javascrpt variables:

    myu = document.getElementById('cid').value;
    myp = document.getElementById('pwd').value;
    window.open("http://localhost:8080/login?cid="+ myu +"&pwd="+ myp ,"MyTargetWindowName");
    

    in the document with that url, you have to read the GET parameters. if it's in php, use:

    $_GET['username']
    

    be aware: to transmit passwords that way is a big security leak!

提交回复
热议问题