I am having a hard time figuring out a solution for my problem. Here's a code snippet:
var ans = prompt("Mot de passe", '');
if (ans != '' && ans != null)
__doPostBack('__Page', ans);
else
window.location = "../Erreurs/NotAuthorized.aspx";
This code works really great with Internet Explorer 9. But my client is exclusively working with Internet Explorer 8 so I tested it with ieTester in IE8. But the problem is that the prompt doesn't show and it automatically redirect because the input had an empty string ('').
So how do I fix this to work with Internet Explorer 8?
It looks like a security thing specific to IE- 8 for sure, I don't have other versions to test. Calling
prompt()
produces a warning about a scripted window asking for information. I can click to allow and after refreshing the page, the prompt box appears as expected.If you are going to insist on using
prompt()
, you will probably have to stipulate that security settings on the target machines are configured to allow it.