Javascript question: How can I still pop up alert after rewriting alert?

Source: Internet
Author: User

Today, I encountered a very interesting question in the group. There are a wide variety of answers that everyone can give. Specially organized into blog posts:

 
// Original question: window. alert = function () {}; ______; alert (1); fill in the blanks to make the following alert (1) pop up correctly. At least two different ideas are listed.

Solution 1: Create a new execution environment and use the IFRAME sandbox

 
Window. alert = function () {}; window. alert = function (OBJ) {var IFRAME = document. createelement ("iframe"); IFRAME. src = "javascript: void (0);" document. body. appendchild (IFRAME) IFRAME. contentWindow. alert (OBJ);} alert (1)

Solution 2: Create a new execution environment and open a new window

 
Window. alert = function () {}; window. alert = function (a) {window. open ('',''). alert (a) // zookeeper createpopup().doc ument. parentwindow. alert (a) // ie only} alert (1 );

Solution 3: Get back the original Alert (ie failed)

Window. Alert = function () {}; window. Alert = function (a) {Delete window. Alert; window. Alert (a) ;}alert (1 );

Solution 4: Same Idea 3 (ie failure)

 
Window. alert = function () {}; window. alert = function (a) {window. _ PROTO __. alert. call (window, a); // window. constructor. prototype. alert. call (window, a);} alert (1 );

Solution 5 (ie Only)

 
Window. Alert = function () {}; execScript ('sub alert (MSG): msgbox MSG: End sub ', 'vbscript'); alert (1 );

Solution 6 is just a dizzy trick.

 
Window. Alert = function () {}; window. Alert = function (a) {window. Confirm (a)} alert (1 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.