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 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    window.open function

    Hi, ive been studing javascript for a little bit, and ive been giving 9 exercise that involve createing a new window, each one of these has the same problem beacause there basically the same just adding more stuff as we go along.

    my code is exactly like my handouts so it has to be somthing simple that the teacher forgot or is being sneaky, i dont want any drastic changes please.


    ----------------------function----------------------------------



    function MakeA Win(){
    win=window.open("","results","toolbar=yes,width=200,height=200,directories=yes
    ,status=yes,scrollbars=yes,resize=yes,menubar=yes");
    win.document.write("<html><head><title>Window2</title></head>");
    win.document.write("<body><h3 align=center>WindowOne</h3>");
    win.document.write("</body></html>");}



    --------------------------form button------------------------

    <form action="">
    <input type="submit" name="mywin" value="Create Window!"
    onclick="MakeA Win()" />
    </form>

    ----------------------------------------------------------------

    this is just bugging me!
    Last edited by sunzini; 03-22-2005 at 09:13 AM.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    What's your question? You didn't mention the problem you're talking about.

    But judging from the script you posted, I can guess that the problem seems to be in the function name. Space is not allowed in function names. Is that a typo?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it doesn't open a new window, try it yourself. And i dont think it's the space in the function name.

  • #4
    Regular Coder
    Join Date
    Dec 2003
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Aside from the function name, you haven't got a comma between
    directories=yes and status=yes...
    UNDER CONSTRUCTION

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    And the button must be a regular button and not a submit button.

    <input type="button" ...>


    and document should be closed after the last document.write.

    win.document.close();


    The popup window may also be blocked by popup blocker installed in your system (if any)
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    i tried all the suggestions and it still doesn't work. Could somebody try the javascript on their browser?

    Im just wondering why my lecturer would make me do it this way.

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Can you post the whole and final code of the page that you're working with? Also what browser are you using?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #8
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sure, here it is. Im using firefox, but ive used opera, and IE


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>New Window</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link href="standard.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" type="text/javascript">
    <!--
    function MakeA Win(){
    win=window.open("","results","toolbar=yes,width=200,height=200,directories=yes
    ,status=yes,scrollbars=yes,resize=yes,menubar=yes");
    win.document.write("<html><head><title>Window 2</title></head>");
    win.document.write("<body><h3 align=center>Window One</h3>");
    win.document.write("</body></html>");}

    //-->
    </script>
    </head>
    <body>
    <form action="#">
    <input type="submit" name="mywin" value="Create Window!"
    onclick="MakeA Win()" />
    </form>
    </body>
    </html>

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Did you really follow all the suggestions?

    If you remove the space in the function name and the newline between "directories=yes" and ",status=yes", it will work.

    To debug, open the Tools->Javascript Console to see javascript errors. That will tell you the exact error and will help you fix it.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #10
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It works's that's great!

    I must have given you the original version.

    Because i tried it with the changes and it still didn't work. It must be my browser or somthing.

    thanks for the help, it's appreciated

  • #11
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Or it must be the user, j/k

    In the future, use the Javascript console to fix errors.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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