0

I need to deactivate a javascript function in all pages that contains "Betteredit" in the URL.

How do I do this?

I found a code I can use to identify the URLs.

$(function() {
    if ( document.location.href.indexOf('Betteredit') > -1 ) {
        $('#elementID').animate({"left": "250"}, "slow");
    }
});

But how can I deactivate a javascript function that is called from a remote library?

Does there exist a way to deactivate a function without editing the library-file, but just overwrite it? Set the function to "false" or something?

This is the function I need to NOT be active in a URL where I use "Betteredit":

(function(a){a.fn.fitVids=function(b){var c={customSelector:null};var e=document.createElement("div"),d=document.getElementsByTagName("base")[0]||document.getElementsByTagName("script")[0];e.className="fit-vids-style";e.innerHTML="&shy;<style>.fluid-width-video-wrapper{width:100%;position: relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top: 0;left: 0;width:100%!important;height:100%!important;}</style>";d.parentNode.insertBefore(e,d);if(b){a.extend(c,b)}return this.each(function(){var f=["iframe[src*='player.vimeo.com']","iframe[src*='www.youtube.com']","iframe[src*='www.kickstarter.com']","object","embed"];if(c.customSelector){f.push(c.customSelector)}var g=a(this).find(f.join(","));g.each(function(){var k=a(this);if(this.tagName.toLowerCase()=="embed"&&k.parent("object").length||k.parent(".fluid-width-video-wrapper").length){return}var h=this.tagName.toLowerCase()=="object"?k.attr("height"):k.height(),i=h/k.width();if(!k.attr("id")){var j="fitvid"+Math.floor(Math.random()*999999);k.attr("id",j)}k.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",(i*100)+"%");k.removeAttr("height").removeAttr("width")})})}})(jQuery);
Community
  • 1
  • 1
Preben
  • 1,277
  • 2
  • 11
  • 20
  • you could just use `if(...) { jQuery.fn.fitVids = $.noop; }` calling it before any elements are initialized by this plugin but better would be to not call this script and unbind all related handlers, if any – A. Wolff Nov 05 '14 at 22:26
  • 1) use a global variable at the beginning, then 2) set it to true when URL contains the string "Betteredit", finally 3) with an if statement load the function when the variable is false. – carlodurso Nov 05 '14 at 23:21

1 Answers1

0

Just to confirm:

A. Wolff had the solution:

I just put that before the inclusion of the other javascript, and it worked well.

$(function() {
    if ( document.location.href.indexOf('Betteredit') > -1 ) {
        jQuery.fn.fitVids = $.noop;
    }
});
</script>
Preben
  • 1,277
  • 2
  • 11
  • 20