[thelist] Javascript pop ups
Joshua Olson
joshua at waetech.com
Sat Jun 29 12:38:01 CDT 2002
----- Original Message -----
From: "Kevin Stevens" <kjs at ratking.co.uk>
Sent: Saturday, June 29, 2002 1:06 PM
> Grrr.. I've been trying to work this out all afternoon and I am finally
> turning to the List for guidance. I'm doing a site for a friend's wedding
> and because there are a lot of names that will be unfamiliar to some
people
> I had the brilliant idea of making the names a link so that when you place
> the cursor over them a pop up window appears with a description of who
that
> person is, and then disappears when you remove the cursor. Before anyone
> mentions this, I know I can do a similar thing with the "title" attribute,
> which is what I might end up doing. The problem is this, I can't seem to
> work out the correct code for the onMouseOut function...
Try this code:
<title>Names</title>
<script language="javascript">
var popup_win;
function popup()
{
popup_win = window.open('whoswho.htm', 'names',
'height=450,width=300,scrollbars=yes')
return false;
}
function popdown()
{
popup_win.close();
return false;
}
</script>
</head>
This code is basically the same as yours except that I am storing a
reference to the window in a global variable (to use it later during the
popdown function), I am excluding from the options list those items that are
"no".... having them in there are option=no is not necessary, and I have the
functions return false.
> 1. When the pop up appears it says Untitled at the top, but you can
clearly
> see I have given it a title.
The title should come from the content of the page, not the second parameter
of the open method. Make sure the whoswho.htm page has a <title> attirbute.
> 2. I have explained I would like the name as a hyperlink, but how can you
> disable the link so if you click on it, nothing happens?
Put the logic in the anchor tag like this:
<a href="" target="names" onMouseOver="return popup();" onMouseOut="return
popdown();">view
names here</a>
Returning false from within the onmouseover and onmouseout triggers disable
the action.
HTH,
-joshua
More information about the thelist
mailing list