Home > front end >  GetComputedStyle () has been an error in the window
GetComputedStyle () has been an error in the window

Time:01-06

 function getCss (curEle, attr) {
Var val=null;
Var reg=null;
If (" getComputedStyle "in Windows) {
Val=window. GetComputedStyle (curEle, null) [attr];
}
The else {
If (attr==="opacity") {
Val.=curEle currentStyle (" filter ");
Reg=/^ alpha \ (opacity=(\ d + (? : \ \ d +)? \]) $/I;
Val=reg. Test (val)? Reg. The exec (val) [1]/100:1;
} else {
Val=curEle. CurrentStyle [attr];
}
}
Reg=/^ (-? \ d + (\ \ d +)?) (px | | a | called rem em pt)? $/I;
Return reg. Test (val)? The parseFloat (val) : val;
}

Written by external js has been an error in the browser. Why?
Please advise
Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Windows' : 1 is not of the type parameter' Element '.

CodePudding user response:

Code no problem, please check whether the incoming curEle parameters for the correct object of dom elements, and elements have been added to the current page,

CodePudding user response:

I also encountered this problem, the building Lord solved excuse me?
  • Related