问题
Our client decided to upgrade to windows 7 and IE 10. Our application which is in 1.1 dot net framework is having issues as it contains vbscript which does not work as soon as user changes the browser mode to IE 10. It works fine if the browser mode is selected as IE 10 compatibility view. It also works fine on IE9,IE8. Vbscript can be as simple as below.
<script language="vbscript">
function ValidateEmail(sEmail)
set myExpression = new RegExp
myExpression.pattern = "^(\w+\.)*(\w+)@(\w+\.)+([a-zA-Z]{2,4})$"
If myExpression.test(sEmail.value) = True Then
msgbox "Valid Email"
Else
msgbox "Invalid Email"
End If
End Function
</script>
We have already tried changing document mode programmatically as can be found on google by adding X-UA-Compatible in web config .
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=9" / >
</customHeaders>
</httpProtocol>
</system.webServer>
Though above code does not work as tag system.webServer does not work for 1.1 dot net framework. We also tried changing the machine config by adding a custom section.Though no success. :(
Can you please provide us a solution by which vbscript can work on IE 10 browser for both browser modes IE 10 as well as IE 10 compatibility view? Thanks in advance.
回答1:
If you're unable to make an http header work, you can use a metatag:
<meta http-equiv="x-ua-compatible" content="IE=9">
Place it as close to the top of the <head>
as possible, ideally before the <title>
element, e.g.
<html>
<head>
<meta http-equiv="x-ua-compatible" content="IE=9">
<title>My webpage</title>
</head>
<body>
<p>Content goes here.</p>
</body>
</html>
There's more information at http://msdn.microsoft.com/en-gb/library/jj676915%28v=vs.85%29.aspx
回答2:
Hmm, I tried your code out in IE 10, under Windows 8. It appears to work in IE 10 as well compatibility mode for me. Perhaps you could give some more info. What else is on the page? Where do you call function?
来源:https://stackoverflow.com/questions/14265443/vbscript-is-not-working-on-ie10-browser-mode