Home Web Front-end JS Tutorial Summary of 2 issues between firefox and ie compatibility_javascript skills

Summary of 2 issues between firefox and ie compatibility_javascript skills

May 16, 2016 pm 06:22 PM
firefox ie compatible

1: The difference between rules and cssRules:
Copy code The code is as follows:

function addCSSRule(css,key,value){
//var css = document.styleSheets[document.styleSheets.length-1];
if(navigator.userAgent.indexOf("Firefox")>0 )
{
css.insertRule(key "{" value "}", css.cssRules.length)
}
else
{
css.addRules(key,value) ;
}
}
function removeCSSRule(key){
for(var i = 0; i < document.styleSheets.length; i ){
var css = document.styleSheets[ i];
navigator.userAgent.indexOf("Firefox")>0 ?
(function(){
for(var j = 0; j < css.cssRules.length; j ){
if(css.cssRules[j].selectorText==key){
css.deleteRule(j);
}
}
})() :
(css. removeRule(key)) ;
}
}

This is how I added a method to solve this problem. .
2: Problem with getting background color in Firefox and IE (difference between getComputedStyle and currentStyle)
Copy code The code is as follows:

function getCurrentStyle(oElement) {
if(navigator.userAgent.indexOf("Firefox")>0 ){
var rgbstr=document.defaultView. getComputedStyle(oElement,null).backgroundColor;
var strR;
if(rgbstr.toString().indexOf('(')>0 && rgbstr.toString().indexOf(')')> 0)
{
strR= rgbstr.toString().substring(parseInt(rgbstr.toString().indexOf('(') 1),rgbstr.toString().indexOf(')')). split(',');
}
return toHexColor(strR[0],strR[1],strR[2]).substring(1);
}
else{
return oElement.currentStyle.backgroundColor.trim().substring(1);
}
}

Copy code The code is as follows:

function toHexColor(r,g,b){
var hex='#';
var hexStr = '0123456789ABCDEF';
low = r % 16;
high = (r - low)/16;
hex =hexStr.charAt(high) hexStr.charAt(low);
low = g % 16;
high = (g - low)/16;
hex =hexStr.charAt(high) hexStr.charAt(low);
low = b % 16;
high = (b - low)/16;
hex =hexStr.charAt(high) hexStr.charAt(low);
return hex;
}

Remember that the rgbstr obtained by Firefox is rgb, so I also need Convert to hexadecimal. I also compiled a very stupid conversion method and then looked at it and hit it!
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)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 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)

How to remove Firefox Snap in Ubuntu Linux? How to remove Firefox Snap in Ubuntu Linux? Feb 21, 2024 pm 07:00 PM

To remove FirefoxSnap in Ubuntu Linux, you can follow these steps: Open a terminal and log in to your Ubuntu system as administrator. Run the following command to uninstall FirefoxSnap: sudosnapremovefirefox You will be prompted for your administrator password. Enter your password and press Enter to confirm. Wait for command execution to complete. Once completed, FirefoxSnap will be completely removed. Note that this will remove versions of Firefox installed via the Snap package manager. If you installed another version of Firefox through other means (such as the APT package manager), you will not be affected. Go through the above steps

The most stable version of Win10 The most stable version of Win10 Dec 25, 2023 pm 07:58 PM

Many users will encounter freezes or blue screens when operating the computer. At this time, we need to find the most stable win10 version to operate. Overall, it is very easy to use and can make your daily use smoother. The most stable win10 version in history 1. Win10 genuine original system. Here users can use simple operations. The system has been optimized and has strong stability, security and compatibility. Users can follow the steps to achieve the perfect machine. 2. Russian master streamlined The version of win10 has been strictly streamlined and many unnecessary functions and services have been deleted. After streamlining, the system has lower CPU and memory usage and runs faster. 3. Win10 Lite Edition 1909 is installed on multiple computers with different hardware models.

Internet Explorer opens Edge: How to stop MS Edge redirection Internet Explorer opens Edge: How to stop MS Edge redirection Apr 14, 2023 pm 06:13 PM

It's no secret that Internet Explorer has fallen out of favor for a long time, but with the arrival of Windows 11, reality sets in. Rather than sometimes replacing IE in the future, Edge is now the default browser in Microsoft's latest operating system. For now, you can still enable Internet Explorer in Windows 11. However, IE11 (the latest version) already has an official retirement date, which is June 15, 2022, and the clock is ticking. With this in mind, you may have noticed that Internet Explorer sometimes opens Edge, and you may not like it. So why is this happening? exist

What should I do if win11 cannot use ie11 browser? (win11 cannot use IE browser) What should I do if win11 cannot use ie11 browser? (win11 cannot use IE browser) Feb 10, 2024 am 10:30 AM

More and more users are starting to upgrade the win11 system. Since each user has different usage habits, many users are still using the ie11 browser. So what should I do if the win11 system cannot use the ie browser? Does windows11 still support ie11? Let’s take a look at the solution. Solution to the problem that win11 cannot use the ie11 browser 1. First, right-click the start menu and select "Command Prompt (Administrator)" to open it. 2. After opening, directly enter "Netshwinsockreset" and press Enter to confirm. 3. After confirmation, enter "netshadvfirewallreset&rdqu

Can mozilla firefox be uninstalled? Can mozilla firefox be uninstalled? Mar 15, 2023 pm 04:40 PM

Mozilla Firefox can be uninstalled; Firefox is a third-party browser and can be uninstalled if it is not needed. Uninstallation method: 1. In the Start menu, click "Windwos System" - "Control Panel"; 2. In the "Control Panel" interface, click "Programs and Features"; 3. In the new interface, find and double-click Firefox Browser icon; 4. In the uninstall pop-up window, click "Next"; 5. Click "Uninstall".

Is Switch2 compatible with Switch cartridges? Is Switch2 compatible with Switch cartridges? Jan 28, 2024 am 09:06 AM

Switch2 is a new model announced by Nintendo at Gamescom 2023. Some players are worried about whether there will be compatibility issues between the new model and the cartridges of previous versions. Let’s take a look. Is switch2 compatible with switch cassette? Answer: switch2 is not compatible with switch cassette. Introduction of Switch 2 cartridges According to information from Nintendo’s production chain company, Switch 2 may use 64GB cartridges. Because it has better performance and supports more 3A game masterpieces, it requires a larger cartridge capacity. Because many game works need to be castrated and compressed before they can be stuffed into a game cartridge. Moreover, Switch cartridges are prone to copying game content, so replace them with new cartridges.

Does Win11 support dynamic wallpapers? Does Win11 support dynamic wallpapers? Jan 01, 2024 pm 06:41 PM

As we all know, a major feature of win11 is its own Android subsystem, which allows us to install Android software without using an emulator. However, there is also the problem of win11 Android application lag. How should this be solved? Is win11 not compatible with dynamic wallpapers? Answer: Win11 is compatible with dynamic wallpapers. If it cannot be used, it may be because the software or system version is lagging behind. If it was just updated, it may be covered by the system wallpaper. 1. If the system or software version is lagging behind, just update the system and dynamic wallpaper software. 2. If it is covered by the system wallpaper, you can try to open "Settings" 3. Then enter the "Background" settings under "Personalization". 4. Then change the personalized background to "Picture" 5. After the modification is completed, you can set the dynamic wallpaper normally

How to cancel the automatic jump to Edge when opening IE in Win10_Solution to the automatic jump of IE browser page How to cancel the automatic jump to Edge when opening IE in Win10_Solution to the automatic jump of IE browser page Mar 20, 2024 pm 09:21 PM

Recently, many win10 users have found that their IE browser always automatically jumps to the edge browser when using computer browsers. So how to turn off the automatic jump to edge when opening IE in win10? Let this site carefully introduce to users how to automatically jump to edge and close when opening IE in win10. 1. We log in to the edge browser, click... in the upper right corner, and look for the drop-down settings option. 2. After we enter the settings, click Default Browser in the left column. 3. Finally, in the compatibility, we check the box to not allow the website to be reloaded in IE mode and restart the IE browser.

See all articles