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.
<a href="javascript:oWin('/html/de/4664286/printregistrationcontent.html?12-security question=Wie heißt Ihr Lieblingsrestaurant','PRINT',800,600);" class="print">Seite drucken</a>
The Problem is the letter 'ß' (sharp S). As you can see the string above is encodes due to anti 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). In the opening window you will only see a square (because character with 65000+ is not printable).
I also tried to use URL Encoding instead of HTML encoding
<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. If i paste this url to the IE8 it will work too, but not if the window is opened by javascript.
The Javascript function oWin is defined as follows
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
Not all browsers encode the href attribute the same way - this could be your problem.
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.
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.
<a href="javascript:oWin('/html/de/4664286/printregistrationcontent.html?12-security question=Wie heißt Ihr Lieblingsrestaurant','PRINT',800,600);"
class="print"
onclick="oWin('/html/de/4664286/printregistrationcontent.html?12-security question=Wie heiß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.
精彩评论