admin管理员组

文章数量:1429321

I try to open multiple browser windows using javascript and the window.open() function. I want to pass a parameter through the query string to my new window like this:

window.open('.aspx?fooparm=1', '_blank');

This opens a new window with the correct address in the address bar but the browser displays a 404-not found. However, if I press enter in this new window, the page loads up correctly.

With a bit of trial and error, I found that using window.open without query string parameters works perfectly:

window.open('.aspx', '_blank');

Is there a limitation I should know about window.open and query string parameters? Is there another way to pass parameters to a new page in a new window?

Thank you very much in advance for your insight.

(Note: This script is generated server-side in C# and injected into the page using Ajax's ScriptManager.RegisterStartupScript.)

I try to open multiple browser windows using javascript and the window.open() function. I want to pass a parameter through the query string to my new window like this:

window.open('http://www.myfoo./foopage.aspx?fooparm=1', '_blank');

This opens a new window with the correct address in the address bar but the browser displays a 404-not found. However, if I press enter in this new window, the page loads up correctly.

With a bit of trial and error, I found that using window.open without query string parameters works perfectly:

window.open('http://www.myfoo./foopage.aspx', '_blank');

Is there a limitation I should know about window.open and query string parameters? Is there another way to pass parameters to a new page in a new window?

Thank you very much in advance for your insight.

(Note: This script is generated server-side in C# and injected into the page using Ajax's ScriptManager.RegisterStartupScript.)

Share Improve this question asked Aug 4, 2009 at 12:10 Danny T.Danny T. 1,14010 silver badges23 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

I found why this morning:

In web.config, under globalization, the responseEncoding was set to "cp037". I changed it to "ISO-8859-15" and my windows are popping up correctly.

<globalization fileEncoding="ISO-8859-15" requestEncoding="ISO-8859-15" responseEncoding="ISO-8859-15" culture="auto" uiCulture="auto"/>

One thing for sure: the limitation is not tied to window.open() pre se. My server runs mod_perl, and I use GET requests in window.open() frequently.

try with

window.open("javascript:window.location='http://www.myfoo./foopage.aspx?fooparm=1'", "_blank");

本文标签: javascriptQuery string parameters do not seem to work with windowopenStack Overflow