[thelist] Preventing default behaviour and event listener

VOLKAN ÖZÇELİK volkan.ozcelik at gmail.com
Mon Jun 6 15:54:10 CDT 2005


Using inline javascript is a bad practice, imo.

I'd do it like:

<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>


And to be accessible to non-js users. The html should be like:

...
<a href="thepopup.html">more information on XYZ (opens on a seperate window)</a>
...


HTH,
Volkan.


On 6/6/05, J.J.SOLARI <jjsolari at pobox.com> wrote:
> Hello,
> 
> A question about event listeners and elements default behaviour.
> 
> I have an event listener associated to a link <a>. It's a click
> event which triggers a function creating a smaller informative popup
> window.
> 
> The intended behaviour is for the window containing the link to stay
> as-is so that one just needs to close the popup window and resume
> browsing on this parent window when finished with the popup.
> 
> There is a simple solution which is to have a 'onclick="return
> false;"' hardcoded into the link.
> 
> But how can it be done without resolving to this solution?
> 
> W3C DOM function preventDefault doesn't seem to be implemented yet
> (at least with Firefox, Safari, Camino).
> 
> TIA,
> 
> JJS
> --
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>


More information about the thelist mailing list