While working on IE10, I have found that the JavaScript functions which are registered or called from the code behind are throwing exception:
"JavaScript runtime error: 'function name' is undefined".
For ex: Code behind in the (!IsPostBack) block:
Page.RegisterStartupScript("showGCAlert", "<script language=\"javascript\">ShowGCAlert();</script>");
PageView:
function ShowGCAlert()
{
alert('GCAlert');
if(document.getElementById('hdnGCAlert').value != "1")
{
document.getElementById('divGCAlert').style.display = "Block";
document.getElementById('chkReminder').focus();
document.getElementById('btnLogin').disabled = true;
document.getElementById('Button2').disabled = true;
}
else
{
document.getElementById('divGCAlert').style.display = "none";
document.getElementById('btnLogin').disabled = false;
document.getElementById('Button2').disabled = false;
if (document.getElementById("txtUsername").value != "")
document.getElementById("txtPassword").focus();
else
document.getElementById("txtUsername").focus();
}
}
When the page loads its throws the exception even though the ShowGCAlert()
exists on the dynamic page.
After continuing the exception design page shows:
<script language="javascript" src="/ABC/DEF/Scripts/Common.js"></script>
<script language="javascript">
document.body.style.overflowY="hidden";
document.body.style.overflowX="hidden";
var jsAppName ='ABC';
</script>
<script language="javascript">
function window.onresize()
{
document.cookie = "resX="
+ document.body.clientWidth
+ ";resY="
+ document.body.clientHeight
+ ";path=/";
}
window.onresize();
</script>
<script type="javascript">
ShowGCAlert();
</script>
<script language="javascript">
document.getElementById('txtPassword').focus();
</script>
In ie9 or IE10 compatibility view its working fine. Please show me where i am doing wrong.