简体   繁体   English

使用javascript打开新窗口时,带有GET参数的IE8中的问题

[英]Problem in IE8 with GET Parameters in opening a new windows with javascript

I have a problem with IE8 and the opening of a new window with javascript and submitting parameters with special characters. 我对IE8和使用javascript并使用特殊字符提交参数打开新窗口时遇到问题。

<a href="javascript:oWin('/html/de/4664286/printregistrationcontent.html?12-security question&#61;Wie hei&#223;t Ihr Lieblingsrestaurant','PRINT',800,600);" class="print">Seite drucken</a>

The Problem is the letter 'ß' (sharp S). 问题是字母“ß”(锐利的S)。 As you can see the string above is encodes due to anti XSS. 如您所见,由于反XSS,上面的字符串是编码的。 This link works in FF and IE6 but IE8 is transmitting the URL Parameter as character with code 65*** (don't know the exaxt value). 该链接适用于FF和IE6,但IE8会将URL参数作为字符传输,并带有代码65 ***(不知道exaxt值)。 In the opening window you will only see a square (because character with 65000+ is not printable). 在打开的窗口中,您只会看到一个正方形(因为不能打印65000+的字符)。

I also tried to use URL Encoding instead of HTML encoding 我也尝试使用URL编码而不是HTML编码

<a href="javascript:oWin('/html/de/4664286/printregistrationcontent.html?12-security question%3DWie hei%C3%9Ft Ihr Lieblingsrestaurant','PRINT',800,600);" class="print">Seite drucken</a>

If i click on this Link in FF or IE6 it works as expected, but IE8 will fail to transmit the "ß" to the server and therefor will also get it back in the wrong way. 如果我在FF或IE6中单击此链接,它会按预期工作,但IE8将无法将“ß”传输到服务器,因此也会以错误的方式将其恢复。 If i paste this url to the IE8 it will work too, but not if the window is opened by javascript. 如果我将此网址粘贴到IE8,它也可以使用,但是如果用javascript打开窗口则不能。

The Javascript function oWin is defined as follows JavaScript函数oWin定义如下

function oWin(url,title,sizeH,sizeV) { 
winHandle = top.open(url,title,'toolbar=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=no,width='+sizeH+',height='+sizeV);
if(navigator.appVersion.indexOf("MSIE 3",0)==-1) id = setTimeout('winHandle.focus()',1000);
} 

If someone has an idea where to look for the reason please answer to this. 如果有人知道在哪里寻找原因,请回答。

Thank you amfa 谢谢你amfa

Not all browsers encode the href attribute the same way - this could be your problem. 并非所有浏览器都以相同的方式对href属性进行编码-这可能是您的问题。 I think you will find that if you move the code to the onclick attribute, it will be handled differently, and more consistently across browsers. 我想您会发现,如果将代码移到onclick属性,它将以不同的方式处理,并且在浏览器之间更加一致。

Adding onclick events in this manner however is not necessarily good design - its best to add handlers in javascript rather than in the attribute tag itself, but it might be worth at least trying. 但是,以这种方式添加onclick事件不一定是好的设计-最好在javascript中而不是在attribute标签本身中添加处理程序,但是至少值得尝试一下。

<a href="javascript:oWin('/html/de/4664286/printregistrationcontent.html?12-security question&#61;Wie hei&#223;t Ihr Lieblingsrestaurant','PRINT',800,600);" 
  class="print"
  onclick="oWin('/html/de/4664286/printregistrationcontent.html?12-security question&#61;Wie hei&#223;t Ihr Lieblingsrestaurant','PRINT',800,600); return false;"
>
  Seite drucken
</a>

...make sure you return false in the onclick handler to prevent the href link being followed. ...确保您在onclick处理程序中返回false,以防止遵循href链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM