Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    opening windows with javascript and passing it variables

    // this is what i am tring to use. the document "."write gives out proper query string, but the window.open only gives upto "?" n nathing after it.

    function openWin(url,ref)
    {
    x=(url+'?'+ref);
    document.write(x);
    window.open(x);
    }


    <a href="javascriptpenWin('email.php','ref=aasim')">this page</a>


    any idea about it

    thanks
    Last edited by aasimajaz; 07-13-2003 at 03:50 AM.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Something like this maybe?


    In the calling document.

    <script language="JavaScript">
    <!--
    function passdata(url,data) {
    var str=data
    window.open(url + '?' + escape(str),'win1','left=300,top=100,width=300,height=300')
    }
    //-->
    </script>
    <a href="#null" onclick="passdata('page2.htm','Hello World')">Pass Data</a>

    In the called document. (page2.htm)

    <script language="JavaScript">
    <!--
    var dataPassed = '';
    if (location.search.length > 0)
    dataPassed = unescape(location.search.substring(1));
    document.write(dataPassed);
    //-->
    </script>
    Last edited by Mr J; 07-13-2003 at 03:31 PM.

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try losing the document.write(x); statement, which should never be called on a loaded document (page).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •