[thelist] Preventing default behaviour and event listener
J.J.SOLARI
jjsolari at pobox.com
Tue Jun 7 03:50:33 CDT 2005
VOLKAN ÖZÇEL†K 6/06/05 22:54 +0300:
><script type="text/javascript">
>function init() {
> document.getElementById("MyLink") = MyLink_Click;
>}
>window.onload = init;
>
>function MyLink_Click(evt) {
> execInformationalPopup();
> return false;
>}
>
>function execInformationalPopup() {
> var params="whatever",
> window.open("thepopup.html",params);
>}
></script>
VOLKAN,
I first used successfully method preventDefault for W3C DOM browsers
(and returnValue=false for IE) to disable normal link behaviour as
in:
function init()
{
stickEvent(document.getMyElementById( "link" ), "click", popWin);
}
function popWin( e )
{
window.open( some url, some name, some parameters );
stopDefault( e );
}
stickEvent() and stopDefault() are both wrapper functions
implementing W3C DOM and IE DOM respective methods and properties.
However, I didn't account for Safari v2.0 not implementing
preventDefault :-(
Finally, I took some inspiration from your script and got to an
acceptable compromise.
Thanks,
JJS.
More information about the thelist
mailing list