Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

JavaScript Invalid Argument

Options
  • 08-07-2004 4:02am
    #1
    Registered Users Posts: 9,190 ✭✭✭


    Hi,

    Bit of a JavaScript problem with the following code:
    function check(){
    var username=document.signup.username.value;
    var check='checkname.php?name='+username;
    checkwindow=window.open(check,'name check','width=300,height=100,resizable=no,scrollbars=no,toolbar=no,location=no,status=no,menubar=no');
    }
    

    It works in firefox (insofar as it doesn't produce any errors and returns my expected results) but I get an "Error: Invalid Argument" with IE.

    I've tried other variations, such as:
    function check(){
    var username=document.signup.username.value;
    checkwindow=window.open('checkname.php?name='+username,'name check','width=300,height=100,resizable=no,scrollbars=no,toolbar=no,location=no,status=no,menubar=no');
    }
    

    with no joy.


Comments

  • Registered Users Posts: 2,781 ✭✭✭amen


    try changing
    document.signup
    to
    window.document.all.signup

    I think you also need to have the
    'width=300,height=100'
    seperated by ;
    'width=300;height=100'


  • Registered Users Posts: 1,268 ✭✭✭hostyle


    Two options (untested, but you'll get the gist of it):

    1. Add an id="username" to the username element and use: var username = document.getElementById('username').value

    2. var username = document.forms("signup").elements("username").value

    document.all is IE only. Its often handy to use alert()'s to debug your code, to see if you're getting expected results. Looking at it again, the error is probably being caused by the second problem outlined by the previous poster. Also I don't think spaces are valid in window names.


  • Registered Users Posts: 9,190 ✭✭✭RobertFoster


    thank you both for the replies.
    Originally posted by amen
    try changing
    document.signup
    to
    window.document.all.signup

    stopped working in firefox, still didn't work in IE.
    Originally posted by amen
    I think you also need to have the
    'width=300,height=100'
    seperated by ;
    'width=300;height=100'

    put the semi-colon in, it got the width right, but the height streched to the full height of my screen.
    Originally posted by hostyle
    Two options (untested, but you'll get the gist of it):

    1. Add an id="username" to the username element and use: var username = document.getElementById('username').value

    2. var username = document.forms("signup").elements("username").value

    neither worked.
    Originally posted by hostyle
    Also I don't think spaces are valid in window names.

    This line only clicked with me when I was editing the quotes above.........and it worked :D cheers!


Advertisement