Home Web Front-end JS Tutorial Difference analysis of each browser's support for link tag onload/onreadystatechange events_javascript skills

Difference analysis of each browser's support for link tag onload/onreadystatechange events_javascript skills

May 16, 2016 pm 06:07 PM
difference

1. onload event

Copy code The code is as follows:





Link Element onload

< ;/HEAD>




IE6/7 :

Difference analysis of each browser's support for link tag onload/onreadystatechange events_javascript skills

IE8/9 :

Difference analysis of each browser's support for link tag onload/onreadystatechange events_javascript skills

Opera :

Difference analysis of each browser's support for link tag onload/onreadystatechange events_javascript skills

That is, IE6/7/8/9/Opera all support the onload event, but Firefox/Safari/Chrome do not support it.

Note: Use JS to create the link tag and add it to the head. The situation is as above.
2, onreadystatechange event

Copy code The code is as follows:




Link Element onreadystatechange
< link type="text/css" rel="stylesheet" href="http://i3.sinaimg.cn/rny/webface/login/css/login101021_min.css" onreadystatechange="alert(this)"/>





Two pop-ups in IE6/7/8/9 This time, other browsers did not play. Note that only IE supports the onreadystatechange event of the link element. It pops up twice: readyState is loading and complete state. ReadyState can be used to determine the loading status. Let’s try using JS to dynamically create link elements,
Copy the code The code is as follows:

< ;!DOCTYPE HTML>



Link Element onreadystatechange


<script> <br>function createEl(type, attrs){ <br>var el = document.createElement(type), <br>attr; <br>for(attr in attrs){ <br>if(attrs.hasOwnProperty(attr)){ <br>el.setAttribute(attr, attrs[attr]); <br>} <br>} <br>return el; <br>} <br>var link = createEl('link', { <br>href : 'http://i3.sinaimg.cn/rny/webface/login/css/login101021_min.css', <br>rel : 'stylesheet', <br>type : 'text/css' <br>}); <br>link.onreadystatechange = function(){ <br>alert(this) <br>} <br>document. getElementsByTagName('head')[0].appendChild(link); <br></script>



IE6/ Still popped up 2 times on 7/8/9. Firefox/Safari/Chrome still doesn't work. Everything seems to be normal, but the amazing thing is that this time it pops up in Opera, indicating that Opera supports the onreadystatechange event when dynamically creating link elements.

Related:

https://developer.mozilla.org/en/HTML/Element/link
http://msdn.microsoft.com/en-us/library/ms535848( v=VS.85).aspx
http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID -35143001

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 Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Comparison and difference analysis between SpringBoot and SpringMVC Comparison and difference analysis between SpringBoot and SpringMVC Dec 29, 2023 am 11:02 AM

SpringBoot and SpringMVC are both commonly used frameworks in Java development, but there are some obvious differences between them. This article will explore the features and uses of these two frameworks and compare their differences. First, let's learn about SpringBoot. SpringBoot was developed by the Pivotal team to simplify the creation and deployment of applications based on the Spring framework. It provides a fast, lightweight way to build stand-alone, executable

In-depth comparison: Analysis of the differences between Dimensity 8200 and Snapdragon In-depth comparison: Analysis of the differences between Dimensity 8200 and Snapdragon Mar 22, 2024 pm 12:48 PM

In the era of mobile Internet, the performance of mobile phones has always been one of the focuses of users. As the leaders in the mobile phone chip market, MediaTek and Qualcomm have also attracted the attention of consumers for their chips. Recently, MediaTek launched the Dimensity 8200 chip, while Qualcomm has its representative Snapdragon series chips. So, what are the differences between these two chips? This article will conduct an in-depth comparative analysis between Dimensity 8200 and Snapdragon. First of all, from the perspective of process technology, Dimensity 8200 uses the latest 6nm process technology, while some of Qualcomm Snapdragon’s

Interpretation of differences between Oracle11g and Oracle12c versions Interpretation of differences between Oracle11g and Oracle12c versions Mar 07, 2024 pm 02:30 PM

Oracle Database has always been one of the leaders in enterprise-level database management systems, and its continuously updated and iterative versions have also attracted widespread attention. Among them, Oracle11g and Oracle12c versions are relatively representative versions and have many differences. This article will explain some important differences between Oracle11g and Oracle12c, and attach specific code examples to help readers gain a deeper understanding of the differences between the two versions. 1. Architecture differences Oracle1

Git or version control? Key Differences in PHP Project Management Git or version control? Key Differences in PHP Project Management Mar 10, 2024 pm 01:04 PM

Version Control: Basic version control is a software development practice that allows teams to track changes in the code base. It provides a central repository containing all historical versions of project files. This enables developers to easily rollback bugs, view differences between versions, and coordinate concurrent changes to the code base. Git: Distributed Version Control System Git is a distributed version control system (DVCS), which means that each developer's computer has a complete copy of the entire code base. This eliminates dependence on a central server and increases team flexibility and collaboration. Git allows developers to create and manage branches, track the history of a code base, and share changes with other developers. Git vs Version Control: Key Differences Distributed vs Set

Quality evaluation: The difference between OnePlus and Honor Quality evaluation: The difference between OnePlus and Honor Mar 23, 2024 pm 12:03 PM

Quality evaluation: The difference between OnePlus and Honor In today’s fiercely competitive environment in the mobile phone market, consumers have increasingly higher quality requirements for mobile phones. Among many mobile phone brands, OnePlus and Honor are among the most popular brands and are favored by consumers. The two have a certain say in the market, but what is the difference in quality? This article will conduct a comparative evaluation between OnePlus and Honor in terms of mobile phone quality, performance, user experience, etc. to help consumers better choose the mobile phone brand that suits them. 1. Appearance design OnePlus mobile phones have always been simple and elegant.

Comparing the differences between Go language and Java: analysis of syntax and programming patterns Comparing the differences between Go language and Java: analysis of syntax and programming patterns Feb 01, 2024 am 08:40 AM

Differences between Go language and Java: Syntax and programming model Go language and Java are both modern and popular programming languages ​​with many similarities, but there are also many differences. These differences are mainly reflected in syntax and programming models. Syntax 1. Variable declaration In Go language, variable declaration requires the use of var keyword, but it is not required in Java. For example: varaintinta; 2. Type inference Go language supports type inference, that is, the compiler can automatically infer the type of variables. For example: a:=10

Compare the differences and comparative analysis between Tomcat and Nginx Compare the differences and comparative analysis between Tomcat and Nginx Dec 28, 2023 am 09:47 AM

Differences and comparisons between Tomcat and Nginx With the rapid development of the Internet, the demand for network applications is getting higher and higher, and web servers have also received more and more attention. As two widely used web servers, Tomcat and Nginx show their respective advantages and characteristics in different scenarios. This article will compare Tomcat and Nginx from different perspectives and explore their differences. 1. Background Before comparing Tomcat and Nginx in depth, let’s first understand their

A deep dive into the differences in stacks in Golang A deep dive into the differences in stacks in Golang Mar 13, 2024 pm 05:15 PM

Golang is a popular programming language with a unique design concept in concurrent programming. In Golang, the management of the stack (heap and stack) is a very important task and is crucial to understanding the operating mechanism of the Golang program. This article will delve into the differences in stacks in Golang and demonstrate the differences and connections between them through concrete code examples. In computer science, stacks are two common ways of allocating memory. They differ in memory management and data storage.

See all articles