admin管理员组

文章数量:1180406

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 says: Please fill in your name

Is there a way to get rid of that?

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?

Share Improve this question edited May 2, 2015 at 8:22 bummi 27.4k14 gold badges65 silver badges104 bronze badges asked Nov 3, 2011 at 14:42 DrewDrew 6,86219 gold badges65 silver badges97 bronze badges 2
  • 3 It's a security measure, to prevent a malicious iframe from tricking you into thinking that the parent page is requesting private information. – Marc B Commented Nov 3, 2011 at 14:44
  • possible duplicate of How to edit a JavaScript alert box title? – Juri Commented Nov 3, 2011 at 14:44
Add a comment  | 

3 Answers 3

Reset to default 26

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.

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).

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

本文标签: iframeJavascript AlertRemoving quotThe page atSaysquotStack Overflow