Closed Bug 121052 Opened 23 years ago Closed 23 years ago

Returning false from onclick does not prevent default action

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
All
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: contact2009, Assigned: joki)

References

()

Details

Using Windows 98, 0.9.7, Build 2002011803. I have set Edit | Preferences |
Advanced | Scripts and Windows | Allow JavaScript to Open Unrequested Windows 
to "off."

When you go to the URL and click on "web opinion and gossip" (time sensitive),
however, you are supposed to go to http://slate.msn.com/?id=2058980. Instead,
Mozilla opens a child window that goes to the new page. The parent window also
goes to the new page. That's redundant.

This is the HTML code that actually causes this problem to happen:

<a
onclick="NewWindow(this.href+'&amp;openerurl='+escape(location.href),'01','750','550','no');return
false;" class="headline" href="?id=2058980"><b><font size="2"
color="#000000">Web opinion and gossip.<br></font></b></a>

Actual behavior: where there was one window, there are now two windows going to
the same page.

Expected behavior: either the child window should open the page and the parent
should not, or the parent should open the page without opening a child window.
The "return false;" should prevent us from going to the new page... And that is
the way it works in Linux trunk build 2002-01-19-06.

The "unrequested windows" pref is very unlikely to be relevant here, but I
tested with it both on and off.
Severity: normal → major
Summary: using onClick, site successfully opens unrequested window → Returning false from onclick does not prevent default action
Seeing same behavior on Linux build 2002012208; OS -> "All".
OS: Windows 98 → All
Well the content onsite has changed but best I can tell this was most likely an
issue with errors in the JavaScript.  'return false' in an onclick handler works
fine right now.  However, if an unhandled exception occurs in the JS before we
get to the return false the JS processing stops and without the return false the
link will be followed.  Given that the site is an MSN site this seems fairly
likely, all it would take was one IE-only JS reference in the function they're
calling.

I'm going to close this invalid for lack of a working testcase.  If one is found
that shows 'return false' broken I'll take another look.  Otherwise this is more
likely to be an Evangelism issue if its errors in the script.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
QA Contact: madhur → rakeshmishra
QA Contact: rakeshmishra → trix
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.