Is Javascript stackable? August 12, 2007 7:22 PMSubscribe
Can Javascript be "stacked" to do an onmouseover AND a popup window all on the one link?
I'm building a website for a friend. I'm pretty good with HTML, but anything I do beyond that (asp, cgi, php, etc) consists of finding snippets of code on the web and molding it to do what I want. In this case, I want to do an onmouseover to swap one image for another, AND open a popup window when the image is clicked. I have the code to do each - but is it possible to put it all together? Here are the snippets of Javascript:
< a href="#"; onmouseover=" document.image.src='image2'" onmouseout=" document.image.src='image'" onmousedown="pop('link')" "> < image name="image"> posted by delmoi at 7:41 PM on August 12, 2007
Your example is missing a " after "[filtered]poptastic('link');
Which means you've probably also got an extra " at the end... posted by Pinback at 7:45 PM on August 12, 2007
thanks for that pinback, by putting in that " I was able to get it to work!
I'm gonna try delmoi's way and Iron Lizard's way too.
Thanks all for the assist. posted by andihazelwood at 7:54 PM on August 12, 2007
Seriously, look at CSS for the rollover effect. Using images for rolling over links is something that has been (thankfully) on it's way out for a number of years now.
Also, take a look at the Javascript Events that are available for inline elements (the a, or anchor tag is an inline element).
As for "stackable", Javascript is incredibly powerful. If you want to combine two or more actions into a single event handler (say, onclick or onmousedown as per delmoi's example above) simply make a function:
function action {
document.image.src = 'image2';
window.open ("http://www.yoururl.com","mywindow","status=1");
}
Then attach it to an event:
<a href="/your/action/here" onclick="action()">link</a> posted by purephase at 4:57 AM on August 13, 2007
« Older Increasing google visitors to ... | SeeADoctorForThisRashFilter: W... Newer »
posted by stopgap at 7:25 PM on August 12, 2007