Page 1 of 1

Javascript Help

Posted: January 4, 2005, 2:36 pm
by Siji
Looking for some simplified instructions on how to add a single line URL for the javascript window.open function/command thing..

I thought I had it down, but everytime I clicked on the link that would open the new window, it would do so.. and also change the source page to a blank page with just [object] for text on it.. Here's what I want to do:

Have a page with text and a link in the text that links to a picture that pops up in a window that is sized to the picture (specifying the window/image size in the html code) when the text is clicked on.

I thought the syntax was simple like

< a href="javascript:window.open('http://www.blah.com/img/image.jpg','win ... height=200')" >link text< /a >

*shrug*


As an added bonus, what's the command for the mouse-over 'tool tip' type text that pops up? (not in a new window, just text).

Posted: January 4, 2005, 3:08 pm
by Fash
best method is...

having a snip of javascript at the top of the file,

Code: Select all

<script language="JavaScript">
function popUp(URL,height,width) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=" + width + ",height=" + height + "');");
</script>
and then use

Code: Select all

<A HREF="javascript:popUp('http://www.whatever.com/whatever',200,200)" alt="pic name">Open the Popup Window</A>
and the tool-tip for links or images is set with the ALT tag.

Posted: January 4, 2005, 3:47 pm
by Siji
Thanks for the javascript stuff, it worked.

I know about the alt text for links.. what I'm wanting is tool-tip type pop-up text for non-links though. Guess I could try using <a without an href link and just alt= in it..