Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-25-2006, 01:18 PM   PM User | #1
michshelly
New Coder

 
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
michshelly is an unknown quantity at this point
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!
michshelly is offline   Reply With Quote
Old 01-25-2006, 01:49 PM   PM User | #2
michshelly
New Coder

 
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
michshelly is an unknown quantity at this point
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
michshelly is offline   Reply With Quote
Old 01-25-2006, 01:50 PM   PM User | #3
SpirtOfGrandeur
Regular Coder

 
Join Date: May 2005
Location: Michigan, USA
Posts: 566
Thanks: 0
Thanked 0 Times in 0 Posts
SpirtOfGrandeur is an unknown quantity at this point
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.
SpirtOfGrandeur is offline   Reply With Quote
Old 01-25-2006, 02:57 PM   PM User | #4
michshelly
New Coder

 
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
michshelly is an unknown quantity at this point
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
michshelly is offline   Reply With Quote
Old 01-25-2006, 03:13 PM   PM User | #5
medigerati
Regular Coder

 
medigerati's Avatar
 
Join Date: Jul 2005
Location: San Antonio, Tx
Posts: 163
Thanks: 0
Thanked 7 Times in 7 Posts
medigerati is on a distinguished road
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.
medigerati is offline   Reply With Quote
Old 01-25-2006, 03:30 PM   PM User | #6
michshelly
New Coder

 
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
michshelly is an unknown quantity at this point
thanks

thanks so very much for your help !!!
michshelly is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:49 AM.


Advertisement
Log in to turn off these ads.