ie9 alert block jsp Render ie8 no problem

  • 2020-06-19 11:31:39
  • OfStack

ie9 jsp rendering may be blocked by alert. There is no problem under ie8.

Problem description:

1 jsp USES JQuery to bind the image initialization event ($(function()), and alert() is used in the initialization event.

When alert pops up the message dialog box under IE8, the jsp page is rendered normally in the browser;

However, under IE9, alert pops up a message dialog box, instantly, the jsp page is not rendered, showing a white page. When clicking "OK" in alert, the page is rendered.

How can IE9 achieve the same effect as IE8?

ie9 compatibility mode has been tried, but it doesn't work. The ie8 parsing mode mandatory in the Jsp code does not work either.

Solutions:

By wrapping alert or confirm in 1 layer of setTimeout.
 
$(document).ready(function() { 
setTimeout(test,0); 
}); 

function test() { 
if(confirm('OK?')) { 
alert("think you!"); 
} 
} 

Guess conclusion:

setTimeout can solve the problem.
setTimeout("alert('XXX')", 0 );
This question is not related to JQuery under ie9. With setTimeout, another thread should be restarted for alert so that it does not prevent jsp from rendering properly.

Related articles: