...

View Full Version : New window?



michshelly
01-25-2006, 01:18 PM
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
01-25-2006, 01:49 PM
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

SpirtOfGrandeur
01-25-2006, 01:50 PM
window.open(linkTarget, "_blank", "toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=no, width=400, height=325");

michshelly
01-25-2006, 02:57 PM
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

medigerati
01-25-2006, 03:13 PM
You also had a comma at the end of you window.open call.

=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:


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

michshelly
01-25-2006, 03:30 PM
thanks so very much for your help !!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum