New issue
Advanced search Search tips

Issue 712106 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Apr 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

function ping() can't be invoked from <a onclick

Reported by atano...@gmail.com, Apr 17 2017

Issue description

UserAgent: 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:
 
PingTest.html
410 bytes View Download

Comment 1 by atano...@gmail.com, Apr 17 2017

if we change function name from 'ping' to another, function is called OK

Comment 2 by phistuck@gmail.com, 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.
Cc: foolip@chromium.org
Status: WontFix (was: Unconfirmed)
I am closing this for now, adding foolip@ to reverse this just in case.

Comment 4 by foolip@chromium.org, 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