Mozilla 도움말 검색

고객 지원 사기를 피하세요. 저희는 여러분께 절대로 전화를 걸거나 문자를 보내거나 개인 정보를 공유하도록 요청하지 않습니다. "악용 사례 신고"옵션을 사용하여 의심스러운 활동을 신고해 주세요.

자세히 살펴보기

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

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

모든 댓글 (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.