A JavaScript fill-in question

Source: Internet
Author: User

Fill in the blanks so that the following alert (0) can be correctly displayed. At least two different ideas are listed.

Window. alert = function () {}; ______; alert (0 );

Solution:

Method 1:

Window. alert = function () {}; delete window. alert; alert (0 );

Getting started with the delete OPERATOR: https://developer.mozilla.org/en/JavaScript/Reference/Operators/delete

It is worth noting that when we mention the return value of the operator, it is described as follows:

Returns false only if the property exists and cannot be deleted. It returns true in all other cases.

If an attribute exists and cannot be deleted, false is returned. Otherwise, true is returned.

Method 2:
Create an iframe and obtain the iframe window. alert to the window. alert of the current page.

Source: mango station Original: Click to view

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.