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 6 of 6

Thread: New window?

  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    New window?

    Hello,
    Can someone please tell me what is wrong with this code? I want it to open in a new window. Here it is:


    <script type="text/javascript">
    <!-- HIDE FROM INCOMPATIBLE BROWSERS

    function showAnimals(linkTarget) {
    animalWindow = window.open(linkTarget, "animalInfo",
    "toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=no,
    width=400, height=325",);
    }

    // STOP HIDING FROM INCOMPATIBLE BROWSERS -->
    </script>
    </head>
    <body>
    <p>

    <a href="koala.html" onmouseover="self.status='Click here to visit the Koala.'; return true"

    onclick="showAnimals('koala.html'); return false">Koala</a><br />

    <a href="manatee.html" onmouseover="self.status='Click here to visit the Manatee.'; return true"

    onclick="showAnimals('manatee.html'); return false">Manatee</a></p>
    </body>
    </html>

    Thanksyou!

  • #2
    New Coder
    Join Date
    Dec 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    I found the problem myself !! lol

    Here's my explanation (as per the book):

    Literal strings must be on a single line. If a line break is included within a literal string, an error is received.

    Well I didn't put a line break in, I just had the options of the Window object's open () method on two lines. eg:
    "toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=no, width=400, height=325");

    I didn't put a line break in there or anything, the browser just read it that way!

    Can someone please explain that too me?
    Thanks

  • #3
    Regular Coder
    Join Date
    May 2005
    Location
    Michigan, USA
    Posts
    566
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    window.open(linkTarget, "_blank", "toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=no, width=400, height=325");
    Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.

  • #4
    New Coder
    Join Date
    Dec 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    line breaks are supposed to be..

    Hello SpirtOfGrandeur

    Thanks for your reply. However I do not understand it.
    I though JavaScript ignored line breaks, spaces and tabs? That's what I've read in this book that I am learning from

    cheers
    Michelle

  • #5
    Regular Coder medigerati's Avatar
    Join Date
    Jul 2005
    Location
    San Antonio, Tx
    Posts
    163
    Thanks
    0
    Thanked 7 Times in 7 Posts
    You also had a comma at the end of you window.open call.
    Code:
    =no, scrollbars=yes, resizable=no,
    width=400, height=325",);
    }
    You can have a line break between the arguments, just not in your options string.

    So this code will also work:

    Code:
    function showAnimals(linkTarget) {
    animalWindow = window.open(linkTarget,
    "animalInfo",
    "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=400,height=325"
    );
    }
    If you need a little more help, I'm available as a Website designer in San Antonio
    ----------
    If I've helped, please check out my friend's nature photography and let me know if you like anything.

  • #6
    New Coder
    Join Date
    Dec 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanks

    thanks so very much for your help !!!


  •  

    Posting Permissions

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