function ping() can't be invoked from <a onclick
Reported by
atano...@gmail.com,
Apr 17 2017
|
||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36 Steps to reproduce the problem: 1. Declare globally function ping() 2. Set call inside <a href="#" onclick="ping(); return false;">Ping</a> 3. Click Ping What is the expected behavior? function is called What went wrong? Uncaught TypeError: ping is not a function Did this work before? N/A Does this work in other browsers? Yes Chrome version: 57.0.2987.133 Channel: stable OS Version: 10.0 Flash Version:
,
Apr 17 2017
I would guess this is working as intended, actually. It reproduces in Safari as well, but it is not a WebKit originated bug in my opinion. You experience a different behavior in other browsers, only because they do not implement the "ping" attribute on <a>. http://caniuse.com/#feat=ping If they were, you would experience the same behavior. If you named your function "rel", for example - <a href="#" onclick="rel(); return false;">Rel</a> It would also fail, since "rel" is also an attribute on <a>, but all of the browsers implement it, so the behavior seems consistent.
,
Apr 17 2017
I am closing this for now, adding foolip@ to reverse this just in case.
,
Apr 26 2017
Sounds like the right analysis. One workaround that might work is to use onclick="window.ping(); return false;" instead, or addEventListener('click', ping). Event handler attributes are weird, as you can see.
|
||
►
Sign in to add a comment |
||
Comment 1 by atano...@gmail.com
, Apr 17 2017