Closed Bug 110939 Opened 24 years ago Closed 23 years ago

resetting document.location doesn't display new page[form sub]

Categories

(Core :: DOM: Core & HTML, defect)

x86
All
defect
Not set
normal

Tracking

()

VERIFIED INVALID
Future

People

(Reporter: bulbul, Assigned: alexsavulov)

Details

Attachments

(1 file, 1 obsolete file)

Resetting document.location doesn't display the new page... at least in the simplest case. It seems that there is some timing involved. If i add an alert to a script right after the location reset, then the new page displays. I'll attach a minimal testcase. This is maddening! I spent hours trying to get a script to work, only to find that this was a Mozilla bug and that the script behaved correctly in Konqueror. Using Linux trunk build 2001-11-18-06.
Attached file test case (obsolete) —
Self-explanatory test case.
worksforme, linux build from 2001-11-18. Definitely sounds like a timing issue.. DOM0, not JS engine
Assignee: rogerl → jst
Component: Javascript Engine → DOM Level 0
QA Contact: pschwartau → amar
Using Mozilla trunk binary 20011120xx on WinNT. Confirming bug. I saved the testcase locally as file:///C:/WINNT/Profiles/pschwartau/Desktop/110939.html When I clicked on the first button ("Change location."), this URL was appended with question mark: file:///C:/WINNT/Profiles/pschwartau/Desktop/110939.html? The URL http://www.fizzylogic.com/ never appeared in the URL bar. And nothing happened. No new page. Note: no errors in JS Console. Reassigning to Form Submission. The upper button uses this HTML: <form name="form1" onsubmit="changeLocation1();"> <input type="submit" value="Change location."> If you change this to <form name="form1"> <input type="button" value="Change location." onclick="changeLocation1();"> then the upper button seems to work fine without the alertbox added....
Assignee: jst → alexsavulov
Status: UNCONFIRMED → NEW
Component: DOM Level 0 → Form Submission
Ever confirmed: true
QA Contact: amar → vladimire
OS: Linux → All
The problem seems to be that when code is executed "onSubmit", the "submit" task doesn't wait for the JavaScript to be complete executed before submitting. (This is just what i surmise after fiddling with a script for a few hours.) Another thing to try is to reset the form's action attribute in the form's onSubmit attribute: <form onsubmit="document.FORMNAME.action=http://www.toothpicksRus.com"> As i recall, the submit will still incorrectly use the old action attribute.
> Another thing to try is to reset the form's action attribute in the form's > onSubmit attribute Oops. I was developing a simple test case for this, and this seems to be working correctly. Sorry i didn't double-check that ahead of time. However, i do know that i have in some case tried to reset the form "action" inside a function call made from onSubmit, where the submit barged ahead, ignoring this variable i had just reset.
Summary: resetting document.location doesn't display new page → resetting document.location doesn't display new page[form sub]
setting milestone
Target Milestone: --- → Future
This seems like expected behavior to me. Here is the sequence of events: 1. submit button clicked 2. onSubmit() called 3. document.location changed, browser starts to change location 4. onSubmit() returns, does not return false (this means it should submit) 5. form submits, changing location again Steps 3 and 5 should act about the same as when you click on link A, it starts loading that link, and then you click on link B. Link B is the one that eventually shows up. Try it. Click on "Show dependency tree" on this page and then quickly click on "Show dependency graph" below it. It will end up on the graph, not the tree. The reason you are seeing it with the alert is the same with links as well. Try it: if you click on "Show dependency tree" and then just before it's about to show the tree page you click on "Show dependency graph", it goes to tree anyway (and stays there). The lesson: return false at the end of onSubmit if you want to make sure you don't submit the form. Not a bug, I say.
Attachment #58508 - Attachment is obsolete: true
For some reason, returning false is _not_ cancelling the form submission. Note that NS4 exhibits the same exact behavior we do...
Your attachment 65940 [details] is not returning false from the javascript, should be <form name="form1" onsubmit="return changeLocation1();"> so the only difference is the delay caused by the alert. First example (attachment 58508 [details]) should be <form name="form1" onsubmit="changeLocation1();return false"> Not all browsers behave like this though!
Ah, indeed. I suck. This bug is invalid, then.
Agreed. This order of events is valid and even preferred.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
verifying
Status: RESOLVED → VERIFIED
Component: HTML: Form Submission → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: