use*_*634 1 javascript jquery function
如果检测到某个浏览器,我将如何删除功能?这是功能和检测:
function parallaxIt(e, target, movement) {
var $this = $("#app");
var relX = e.pageX - $this.offset().left;
var relY = e.pageY - $this.offset().top;
TweenMax.to(target, 1, {
x: (relX - $this.width() / 2) / $this.width() * movement,
y: (relY - $this.height() / 2) / $this.height() * movement,
z: 0.01,
rotation:0.01
});
}
var version = detectIE();
if (version === false) {
//Do Nothing
} else if (version >= 12) {
//Remove Function
} else {
$("#iefix").attr({href : "/static/css/app-iefix.css"});
//Remove Function
}
Run Code Online (Sandbox Code Playgroud)
因此,当检测到任何 IE 时,我想删除该功能parallaxIt()或破坏它,因此它不起作用任何想法?亲切的问候
(代码的检测部分显然是完整代码的一小段,所以你们更容易阅读而不是阅读完整代码)
至少对于我在 Chrome v71 (Windows 10) 中,删除该功能不会做任何事情(它保持存在)。但是您可以将其重新分配为无操作功能:
function parallaxIT() {
console.log("inside parallaxIT");
}
// delete
delete window.parallaxIT;
console.log("parallaxIT was 'deleted', does it still show output:");
parallaxIT();
console.log("=====");
// re-assign
window.parallaxIT = function() {} // no-op function
console.log("parallaxIT was re-assigned, does it still show output:");
parallaxIT();
console.log("=====");Run Code Online (Sandbox Code Playgroud)