Having trouble with window.open and _self

if I do this:

window.open(url_var,‘_self’);

it works in IE but not in FF or chrome.

but this:

window.open(url_var);

works in all 3 but opens a new window…I want to stay in the same window.

Can I get a clue?

THanks!!

Hmm why are you trying to window.open a link a the same window? There are other ways to redirect :stuck_out_tongue:

because the url the page is going to is dynamic and based on user input.

But why don’t you simply use “window.location.href = ‘your_new_url’;” ?

(I’m sorry it’s just that I find it odd to use window.open, which is specifically made to open a new window, to redirect in the same window :stuck_out_tongue: Even though I see it can be done from MSDN doc here http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx )

ohh ok thanks…ill try that.

ok so I tried that…same thing tho, works in IE but not in FF or chrome…

Well it works for me in FF. Perhaps there’s some other problem on your page preventing it from working?

Perhaps you changed the configuration in FF to specifically open new pages in a particular way rather than the way the page requests.

Well heres the page… http://www.kranichs.com/a_search.php you can change the drop downs and then when you click the find button is when this happens.

Thanks.

Well I tried it and I was redirected when I clicked find. I’m using FF3.

Thanks…maybe theres just something wrong with my computer then because when I do it…the page just refreshes but I stay on the same page…IU am using FF3 and chrome.

Well it does come back to the same page, but with a different URL (ie. the query string in the URL contains the parameters of the form).

yeah but its supposed to go to a different page with that qry string ie my code looks like this:

window.location.href = ‘a_category.php?prev_value=’+prev_value;

but the current page is a_search.php

Thanks again!

Well sorry I can’t come up with the solution, but at least I can see this: using Tamper Data (a Firefox net sniffing plugin), I can see that category.php IS requested but never receives a reply from server, and somehow Firefox is instantly loading a_search.php again.

Hope that helps more than it confuses…

hmmmm, that should work. Post some more of the code, could be something else not working. Could it maybe be a submit button in a form with the action set to the current page or something funny?

Actually NightStalker-DNS probably pinpointed the problem. If instead of clicking the <button> I type:

javascript:void(find_results())

after having selected elements in the form, I am redirected correctly to the a_category.php page.

Btw it makes sense since <button> has the following property:

“The type attribute should always be specified. The default button type for Internet Explorer is “button”, while in other browsers (and the W3C specification) it is “submit””

So specify the type to button maybe?

You could try and do that, or change it to a link even and style it to look like a button.

Instead of input type button, use the <button> tag

Hope it works out

Thanks guys…not only did I fix the problem but I learned some new stuff as well…THANKS!!