Home Web Front-end JS Tutorial Code to determine whether the target is window, document, and Element with tagName_javascript skills

Code to determine whether the target is window, document, and Element with tagName_javascript skills

May 16, 2016 pm 06:26 PM
document window Target

复制代码 代码如下:

function isWindow( obj )
{
if( typeof obj.closed == 'undefined' ) return false;
var result = /[object (window|global)]/i.test( Object.prototype.toString.call( obj ) );
if( result )return result;
try{
obj.closed = obj.closed;
return false;
}catch(e)
{
result = true;
}
return result;
}
function isDocument( obj )
{
if( typeof obj.body == 'undefined' ) return false;
var b = obj.body;
try{
obj.body = null;
obj.body = b;
return false;
}catch(e)
{
return true;
}
}
function isElement( o )
{
var tn = 'tagName',temp = o[tn],result;
if( typeof temp == 'undefined' )return false;
try{
o[tn] = null;
result = ( temp == o[tn] );
o[tn] = temp;
return result;
}catch(e)
{
return true;
}
}

function getOwnerWindow( node )
{
if( isWindow( node ) )return node;
var doc = isDocument( node ) ? node : node.ownerDocument;
return doc.view || doc.parentWindiw || doc.defaultView;
}

需要充分测试
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem that document.cookie cannot be obtained How to solve the problem that document.cookie cannot be obtained Nov 23, 2023 am 10:02 AM

Solutions for document.cookie not being obtained: 1. Browser privacy settings; 2. Same-origin policy; 3. HTTPOnly Cookie; 4. JavaScript code error; 5. Cookie does not exist or expires; 6. Cross-domain issues; 7. Viewer mode; 8. Server problems; 9. JavaScript execution timing; 10. Check console log, etc.

GTA 6 document gives a detailed overview of all leaks GTA 6 document gives a detailed overview of all leaks Sep 08, 2024 am 06:37 AM

On September 3, version 1.5 of the Grand Theft Auto VI document which provides a detailed overview of everything that is known about the game to date. The updated version of the document was announced in a trailer published on X (formerly Twitter).??

Regression meta-learning, few-sample target detection based on variational feature aggregation to achieve new SOTA Regression meta-learning, few-sample target detection based on variational feature aggregation to achieve new SOTA Apr 12, 2023 pm 06:46 PM

Different from traditional object detection problems, few-shot object detection (FSOD) assumes that we have many basic class samples but only a small number of novel class samples. The goal is to study how to transfer knowledge from basic classes to novel classes, thereby improving the detector's ability to recognize novel classes. FSOD usually follows a two-stage training paradigm. In the first stage, the detector is trained using rich base class samples to learn the common representations required for object detection tasks, such as object localization and classification. In the second stage, the detector is fine-tuned using only a small number (e.g. 1, 2, 3...) of novel class samples. However, due to the imbalance in the number of basic class and novel class samples, the model learned is usually biased towards the basic class, which leads to the novel class target being different from the similar basic class.

'Unexpected Duck' annual goal clearance strategy 'Unexpected Duck' annual goal clearance strategy Jan 27, 2024 pm 09:15 PM

"Unexpected Duck" is a casual puzzle game that has become very popular on Douyin recently. It has a lot of updated levels, some of which are relatively difficult. Today, the editor of this website will share with you the strategy for clearing the annual goal of "Unexpected Duck" to help girls achieve their annual goals. In this level, we need to use the props in the scene to help the girl achieve her goal. If you don’t know how to pass this level, hurry up and take a look at the pictures and texts below! "Unexpected Duck" Annual Goal Clearance Guide Annual Goal Goal: Help girls complete the annual goal. The answer is as shown below: 1. Drag the pen to target 1, and then drag the net bag on the ground to the girl's hand. 2. Drag the hammer to the target. 2. Drag another 200 yuan into the piggy bank. 3. Drag the pen to target 3, and then click

Genshin Impact: Our goal is in another channel guide Genshin Impact: Our goal is in another channel guide Mar 14, 2024 pm 10:37 PM

In the Genshin Impact game, our target is in another pipeline. This is a new world mission, but many players don’t know how to do it. Players need to repair the pipeline in Merlo Petersburg. More details. In this article, our goal is in another pipeline graphic guide, I hope it will be helpful to all players. Genshin Impact: Our Target is in Another Pipeline Strategy 1. First, players need to come to the dock to talk to Aigui to receive the task. 2. Then go to the first place and use the ability of the heterochromatic hunting knife ray to cut off the seaweed to obtain the hand wheel. 3. Then install the handwheel and turn it twice. 4. Then come to the second place and rotate once. 5. When you reach the third place, you need to plant the bomb first to eliminate the red villain. 6. Then turn the top one once and the bottom three times. 7. Finally came to the fourth

How to solve Windows worm virus How to solve Windows worm virus May 17, 2023 pm 07:22 PM

0x00 Preface The worm is a very old computer virus. It is a self-contained program (or a set of programs) that usually spreads through the network. Every time it invades a new computer, it is on this computer. Makes a copy of itself and automatically executes its own program. Common worms: Panda Burning Incense Virus, Shock Wave/Shock Wave Virus, Conficker Virus, etc. 0x01 Emergency Scenario One morning, the administrator found at the egress firewall that the internal network server continued to initiate active connections to overseas IPs. The internal network environment was unable to connect to the external network, and there was no way to figure it out. 0x02 event analyzes the server's intranet IP seen on the egress firewall. First, disconnect the virus-infected host from the intranet, then log in to the server, open D-shield_web scan and check

Detailed graphic tutorial for installing Windows 10 tablet system Detailed graphic tutorial for installing Windows 10 tablet system Jul 14, 2023 am 09:33 AM

Tablet computers are currently very popular computers among many young people. Recently, many friends want to know how to install the Windows 10 tablet system, so today I will share with you a very simple one-click method to install Windows 10. Let’s take a look below! Detailed graphic tutorial for installing Windows 10 tablet system: 1. We search and download Xiaobai’s one-click reinstallation system software, choose to download and install the Win10 operating system, and click to install this system. 2. Wait for Xiaobai to download and deploy the environment. 3. After the deployment is completed, click Restart Now. 4. Choose to enter the Xiaobai pe system. 5. After entering the pe system, the installation tool will pop up to help us automatically reinstall the system. We do not need any operations.

Windows 10 reinstall win7 system tutorial Windows 10 reinstall win7 system tutorial Jul 08, 2023 pm 05:45 PM

Many friends are not used to using the win10 system and want to reinstall the win7 system, but they don’t know how to start. The editor will teach you this simple method below. Friends who don’t know how to reinstall windows7 on the computer should not miss it. 1. First, we open the computer browser and search the official website of Magic Pig One-Click System Reinstallation, download it and open it. 2. After downloading, we open it and click online reinstallation. 3. Next, we will wait patiently for it to be installed. 4. The installation is complete. Next we need to click to restart the computer now. 5. After restarting the computer, we still need to return to the main interface to continue completing the installation. Then our installation is completed. The above are the steps for reinstalling the win7 system in windows 10. I hope it will be helpful to everyone.

See all articles