Om de ûnderfining foar jo te ferbetterjen is tydlik de funksjonaliteit dan dizze website troch ûnderhâldswurk beheind. Wannear in artikel jo probleem net oplost en jo in fraach stelle wolle, kin ús stipemienskip jo helpe yn @FirefoxSupport op Twitter en /r/firefox op Reddit.

Sykje yn Support

Mij stipescams. Wy sille jo nea freegje in telefoannûmer te beljen, der in sms nei ta te stjoeren of persoanlike gegevens te dielen. Meld fertochte aktiviteit mei de opsje ‘Misbrûk melde’.

Mear ynfo

Dizze konversaasje is argivearre. Stel in nije fraach as jo help nedich hawwe.

setting window.location in javascript doesn't work unless i have an alert

  • 2 antwurd
  • 3 hawwe dit probleem
  • 7 werjeftes
  • Lêste antwurd fan AnonymousUser

more options

I am attempting to jump to a new URL from a string that I've patched together in javascript. If I just use window.location = newurlstring firefox just reloads my current page. But it I put an alert after i set the new location, then it jumps. I have a very stripped down version of what I'm trying to do at http://www.secretarea51.com/Searches/search2.htm That page has two buttons. Both call the same javascript function but with different parameters. One does an alert after attempting to set the new location, the other bypasses the alert. If the alert is bypassed, all that happens is the current page gets reloaded. If the alert is not bypassed, then the new page does get loaded. You can look at the source for the page. I've stripped it down to about the bare minimum that I could to demonstrate the problem I'm having. I'm sort of new to javascript, but as best as I can tell, there shouldn't be a difference between the two situations.

This happened

Every time Firefox opened

== ever since I've tried it

I am attempting to jump to a new URL from a string that I've patched together in javascript. If I just use window.location = newurlstring firefox just reloads my current page. But it I put an alert after i set the new location, then it jumps. I have a very stripped down version of what I'm trying to do at http://www.secretarea51.com/Searches/search2.htm That page has two buttons. Both call the same javascript function but with different parameters. One does an alert after attempting to set the new location, the other bypasses the alert. If the alert is bypassed, all that happens is the current page gets reloaded. If the alert is not bypassed, then the new page does get loaded. You can look at the source for the page. I've stripped it down to about the bare minimum that I could to demonstrate the problem I'm having. I'm sort of new to javascript, but as best as I can tell, there shouldn't be a difference between the two situations. == This happened == Every time Firefox opened == ever since I've tried it

Alle antwurden (2)

more options

Hmmm... It would seem as though the problem has to do with the type="submit" that I had in the input tags for the buttons. I took that out and now it does the jump with or without the alert.

Now I've just got to find out how to make it look like a button without the type="submit" in there. But I can do that part.

You can scratch this from the bug list or whatever this is. Maybe shift it to an oddities list or something because I still don't know why the original behavior would be different whether there's an alert or not.

more options

I think you can only have one type="submit" per form. To understand it better, instead of using the onclick="doSearch(1);" attribute on the input element, use the action="javascript:doSearch(1);" attribute on the form element. So it's one submit action per form.