Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Kërkoni te Asistenca

Shmangni karremëzime gjoja asistence. S’do t’ju kërkojmë kurrë të bëni një thirrje apo të dërgoni tekst te një numër telefoni, apo të na jepni të dhëna personale. Ju lutemi, raportoni veprimtari të dyshimtë duke përdorur mundësinë “Raportoni Abuzim”.

Mësoni Më Tepër

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

  • 2 përgjigje
  • 3 e kanë hasur këtë problem
  • 7 parje
  • Përgjigjja më e re nga 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

Krejt Përgjigjet (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.