Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Alert - Removing "The page at ??? Says"

I have a form and I am using Javascript to validate the form so if you leave a field blank it will alert "Please fill in your Name".

If I go to the link directly, it works perfectly. But this is kind of like a Widget so I am using an iFrame to embed it into other sites. When I embed it, and click Submit with an empty field it says: The page at http://www.example.com says: Please fill in your name

Is there a way to get rid of that?

like image 872
Drew Avatar asked Nov 03 '11 14:11

Drew


People also ask

Can you customize alert JavaScript?

SweetAlert is a JavaScript library used to customize alerts in web applications and websites with the help of a button. You can utilize its “Swal. fire()” method to create an alert box and customize it using CSS.

What is alert () function in JavaScript?

The alert() method displays an alert box with a message and an OK button. The alert() method is used when you want information to come through to the user.

How do you create an alert popup in JavaScript?

JavaScript Popup Boxes: Summary If you want to display an alert of some kind to a user, use alert() . If you want to display a confirmation box with option buttons, use confirm() . If you want to use a pop up with an input and option buttons, which can display inputed values, use prompt() .

Does JavaScript alert stop execution?

One of the nice things about the built-in JavaScript alert is that - unlike virtually anything else in JavaScript - it's synchronous. It's completely blocking, and no other code will execute until it's been dismissed.


3 Answers

No, there isn't. It is an anti-phishing feature.

If you want a dialog without it, then you have to fake it using HTML elements in your page.

like image 113
Quentin Avatar answered Nov 12 '22 07:11

Quentin


For those who are still looking to use the native alert/confirm, it's not that hard to get past the anti-phishing implementation. This is because the iframe can edit the parent and access it's scope.

Try this:

parent._alert = new parent.Function("alert(arguments[0]);");
parent._alert('Test!');

The reason this works is because new Function('') does not create a closure and instead uses the scope of where Function is defined (via parent.Function).

like image 43
Nejuf Avatar answered Nov 12 '22 08:11

Nejuf


You can use some custom alert plugin. For example http://stefangabos.ro/jquery/zebra-dialog/

like image 1
webtech Avatar answered Nov 12 '22 08:11

webtech