Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prompt() with Internet Explorer 8

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?

like image 883
Soader03 Avatar asked Apr 17 '12 18:04

Soader03


4 Answers

IE has an setting in Internet Options to allow or deny prompt().

IE prompt setting
(source: adamhaskell.net)

By default in IE8, this setting is off. Consequently, calls to prompt() are ignored and "" is returned by them.

You shouldn't use prompt() anyway. Use a form.

like image 121
Niet the Dark Absol Avatar answered Oct 23 '22 04:10

Niet the Dark Absol


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.

like image 23
lincolnk Avatar answered Oct 23 '22 06:10

lincolnk


Microsoft developer website tells us that "prompt()" is deprecated and now normally blocked for security reasons: "By default, this method is blocked by the information bar in the Internet zone. This helps prevent malicious sites from initiating spoofing attacks. "

See http://msdn.microsoft.com/en-us/library/ms536673.aspx

like image 28
Meier Avatar answered Oct 23 '22 05:10

Meier


From this report it looks like it's a known bug in IETester?

http://www.my-debugbar.com/forum/t294-Javascript-Alerts.html

like image 1
Jamund Ferguson Avatar answered Oct 23 '22 06:10

Jamund Ferguson