How do I prevent, stop, or kill Javascript function?

自闭症网瘾萝莉.ら 提交于 2020-01-02 02:52:06

问题


How do I prevent this Javascript function from executing.

I have a js function that is causing a serious issue and I am not able to remove nor modify it source. I would like to know if it is possible to simply prevent, stop, or kill the function in order that it is not executed till I resolve the issue.

So somewhere inside the page:

<script type="text/javascript"><!--
problem_func();
//--></script>

And all I want is to stop that function from execution placing a stopper inside the header or external js.

Any advice?

HERE IS THE LIVE EXAMPLE, HOW TO STOP THAT? http://jsbin.com/uxalag/3


回答1:


If you know the function name, you can replace it with a function that does nothing. After the script tag of the source js file use this:

window.FunctionName=function(){return false;};



回答2:


Just overwrite it

for example if a function abc() { ..... } causing you problem you can overwrite it with an empty body.

function abc() {  }


来源:https://stackoverflow.com/questions/9684799/how-do-i-prevent-stop-or-kill-javascript-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!