Closed Bug 281949 Opened 20 years ago Closed 20 years ago

Page reloads with "return false" in onclick when href=""

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

VERIFIED WORKSFORME

People

(Reporter: kenneth_kolano, Assigned: bugzilla)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

Placing "return false" in an onclick handler should prevent the link from being
followed. This isn't the case when the href is blank. In that case the page
innappropriately refreshes.

Reproducible: Always

Steps to Reproduce:
1.Load test page...
<html>
<body>
<script type="text/javascript">
document.write(new Date())
</script>
<br />
<a href="" onclick="return false">href="" (should not refesh time above)</a>
<a href="Something" onclick="return false">href="Something" (does not refesh
time above)</a>
</body>
</html>
2.Click first link
Actual Results:  
Time displayed refreshes indicating the page has reloaded

Expected Results:  
Clicking those links should do nothing
Attached file reporter's testcase
WFM in 1.0 and latest-nightly on WinXP: no reload from either link.
Works for me as well.

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b) Gecko/20050211 Firefox/1.0+
Hrm, double checked this.

If I view the test directly it works as it should. If I deploy it to my
webserver it's buggy as I indicate here. Please ensure you are trying the test
page from a server.
Um, bugzilla.mozilla.org *is* a web server. But just to make quintuply sure,
even though it can't make a difference, http://philringnalda.com/mtests/onclick/
sends every "don't cache this" header, and it still works.

Don't hesitate to reopen if you can provide the URL for a non-working example,
so we can see what your server is doing or what might cause the problem, but as
it is there's no way we can fix it because we can't see anything not working.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → WORKSFORME
Status: RESOLVED → VERIFIED
Odds are the page on your server contains a typo or some other mistake. Did you
try uploading Phil's testcase to you server?

In any case, there is absolutely no reason why different webservers would make
that testcase produce different results.
Hrm. I'm still experience this using the testcase on bugzilla, though I probably
should be trying on a fresh install. I'll assume its some odd extension conflict.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: