Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove onload event from body tag [duplicate]

I've this government site page and using developer console I want to remove the onload event attached to the body tag by entering this code in the console:

var script = document.createElement("script");
script.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.head.appendChild(script);

//wait for jquery library to load
setTimeout(function(){ 
$("body").unbind("onload");

$("body").get(0).onload = null;

 }, 3000);

But that does not work.

What is the way to remove this handler from attached javascript code? Since I'll need to remove it using an attache JS code in Google Chrome Extension.

I've not yet tried this code in Google Chrome Extension. First I want to make it work using developer console.

like image 316
user5858 Avatar asked Nov 10 '22 12:11

user5858


1 Answers

The following JQuery will remove the onload function from your body tag:

$('body').off('load');

See more about off here

like image 95
Toni Leigh Avatar answered Nov 14 '22 22:11

Toni Leigh