Click to See Complete Forum and Search --> : Trying to get a pop-up window from pressing a link - not working


CalifNina
06-20-2003, 01:49 PM
I know this is so simple and stupid ... but I'm simply trying to have a text-link within a paragraph, that when selected brings up a second smaller window. That's it... this is my first time trying this. Code is incorrect somewhere. Help please.

HEAD section:<SCRIPT TYPE="text/javascript"> //Opens new window "testpage.html"
<!--
function openWindow()
{
window.open("testpage.html","myWindow","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory= yes,width=400,height=400")
}
//-->
</SCRIPT>
BODY section: (I'm betting this is the error-prone area??)<P>paragraph text paragraph text paragraph text <STRONG><A HREF onclick="openWindow()">click here for test page</A></STRONG> paragraph text paragraph text paragraph text.</P>
I don't know how to do this. :mad: It's gotta be the whole A HREF onclick combination??? ... need someone to please critique and find my code or logic error(s)??

Charles
06-20-2003, 01:57 PM
<P>paragraph text paragraph text paragraph text <STRONG><A HREF="testpage.html" onclick="window.open(this.href, 'myWindow', 'width=400,height=400,status,copyhistory'); return false">click here for test page</A></STRONG> paragraph text paragraph text paragraph text.</P>

CalifNina
06-20-2003, 02:10 PM
Charles, perfect!! My second window works now. Gracias!! :D

CalifNina
06-20-2003, 02:34 PM
Charles, even though it worked perfect, I do have a question: you reiterated some attributes I had in the openwindow() function into the A HREF statement in the paragraph, I don't understand that part.

i.e.,<A HREF="testpage.html" onclick="window.open(this.href, 'myWindow', 'width=400,height=400,status,copyhistory'); return false">click here for test page</A>The extra or restated parts are:('myWindow', 'width=400,height=400,status,copyhistory')Does that mean those same attributes I had in the openwindow() function are ignored and only those attributes in the A HREF statement are valid?? I'm not sure what to keep in each section. How do I clean up the openwindow() function and then the A HREF text-link?? This part has me lost.

Meaning, what do I keep in the HEAD section, what do I keep in the BODY section?

Charles
06-20-2003, 02:42 PM
The part that I posted works all by itself; there's really no need to split up such a little script. Just go ahead and delete what you had in your document's HEAD.

And note, that if you specify the height and width of a child window then all the other features default to off - there's no need to specify scrollbars=no - and you can include a feature by simply using its name.

CalifNina
06-20-2003, 02:49 PM
ohhhh wow really?? ok!! Just learned a whole bunch on this then on what is needed (and not). I'll go delete the openwindow() routine in the head section.

Thank you for all the tidbits, I think I got it now! way cool.