Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

JavaScript Invalid Argument

  • 08-07-2004 04:02AM
    #1
    Registered Users, Registered Users 2 Posts: 9,446 ✭✭✭


    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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 9,446 ✭✭✭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