Discussion:
remove onLoad event before execution using greasemonkey?
+Ramin+
2007-10-09 22:22:06 UTC
Permalink
I have:
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);">
The body goes here...
</body>
</html>
--------- end HTML --


I need to parse this html with a greasemonky script so that I remove
the onLoad event and get the following:
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="">
The body goes here...
</body>
</html>
--------- end HTML --


My script looks like this:
-- begin JavaScript ------------------------
// ==UserScript==
// @name Remove Offending Autoresize
// @namespace http://userscripts.org/RemoveOffendingAutoresize
// @description Remove Offending Autoresize for foo.com
// @include *
// ==/UserScript==
function main()
{
document.documentElement.body.onLoad.value = "";
}

main();
--------------------- end JavaScript -----


Why is it not working?
Your help is appreciated :)
-Ramin


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-***@googlegroups.com
To unsubscribe from this group, send email to greasemonkey-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Tom Most
2007-10-10 01:29:28 UTC
Permalink
You want

document.body.setAttribute("onload", "");

--Tom
Post by +Ramin+
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);">
The body goes here...
</body>
</html>
--------- end HTML --
I need to parse this html with a greasemonky script so that I remove
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="">
The body goes here...
</body>
</html>
--------- end HTML --
-- begin JavaScript ------------------------
// ==UserScript==
// ==/UserScript==
function main()
{
document.documentElement.body.onLoad.value = "";
}
main();
--------------------- end JavaScript -----
Why is it not working?
Your help is appreciated :)
-Ramin
+Ramin+
2007-10-10 02:34:04 UTC
Permalink
Thank you Tom. It worked.

Just one point: when I view the document with DOM inspector, the
attribute for 'onload' is set to empty but when I view the page source
(right click on the page, 'View Page Source') the attribute is not
changed... Do you know why?

Thanks,
-Ramin
Post by Tom Most
You want
document.body.setAttribute("onload", "");
--Tom
Post by +Ramin+
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);">
The body goes here...
</body>
</html>
--------- end HTML --
I need to parse this html with a greasemonky script so that I remove
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="">
The body goes here...
</body>
</html>
--------- end HTML --
-- begin JavaScript ------------------------
// ==UserScript==
// ==/UserScript==
function main()
{
document.documentElement.body.onLoad.value = "";
}
main();
--------------------- end JavaScript -----
Why is it not working?
Your help is appreciated :)
-Ramin
smime.p7s
4KDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-***@googlegroups.com
To unsubscribe from this group, send email to greasemonkey-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Tom Most
2007-10-10 06:05:25 UTC
Permalink
The View Source menu option displays the file as it was loaded from the
server--it does not reflect the changes made to the DOM by scripts. If
you want to view the source corresponding to the current DOM you can
select all (or just a portion) of the document, right click on the
selection, and hit "View Selection Source". If you find yourself using
this feature a lot then I recommend that you install the Firebug
extension--it's inspect feature gives you a live view of the DOM that
updates in real time, which can be very useful for observing the changes
scripts make.

--Tom
Post by +Ramin+
Thank you Tom. It worked.
Just one point: when I view the document with DOM inspector, the
attribute for 'onload' is set to empty but when I view the page source
(right click on the page, 'View Page Source') the attribute is not
changed... Do you know why?
Thanks,
-Ramin
Post by Tom Most
You want
document.body.setAttribute("onload", "");
--Tom
Post by +Ramin+
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);">
The body goes here...
</body>
</html>
--------- end HTML --
I need to parse this html with a greasemonky script so that I remove
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="">
The body goes here...
</body>
</html>
--------- end HTML --
-- begin JavaScript ------------------------
// ==UserScript==
// ==/UserScript==
function main()
{
document.documentElement.body.onLoad.value = "";
}
main();
--------------------- end JavaScript -----
Why is it not working?
Your help is appreciated :)
-Ramin
smime.p7s
4KDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---
+Ramin+
2007-10-10 19:18:51 UTC
Permalink
Excellent extension :)
Thanks again for your help Tom.
Post by Tom Most
The View Source menu option displays the file as it was loaded from the
server--it does not reflect the changes made to the DOM by scripts. If
you want to view the source corresponding to the current DOM you can
select all (or just a portion) of the document, right click on the
selection, and hit "View Selection Source". If you find yourself using
this feature a lot then I recommend that you install the Firebug
extension--it's inspect feature gives you a live view of the DOM that
updates in real time, which can be very useful for observing the changes
scripts make.
--Tom
Post by +Ramin+
Thank you Tom. It worked.
Just one point: when I view the document with DOM inspector, the
attribute for 'onload' is set to empty but when I view the page source
(right click on the page, 'View Page Source') the attribute is not
changed... Do you know why?
Thanks,
-Ramin
Post by Tom Most
You want
document.body.setAttribute("onload", "");
--Tom
Post by +Ramin+
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);">
The body goes here...
</body>
</html>
--------- end HTML --
I need to parse this html with a greasemonky script so that I remove
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="">
The body goes here...
</body>
</html>
--------- end HTML --
-- begin JavaScript ------------------------
// ==UserScript==
// ==/UserScript==
function main()
{
document.documentElement.body.onLoad.value = "";
}
main();
--------------------- end JavaScript -----
Why is it not working?
Your help is appreciated :)
-Ramin
smime.p7s
4KDownload
smime.p7s
4KDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-***@googlegroups.com
To unsubscribe from this group, send email to greasemonkey-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---
+Ramin+
2007-10-10 19:34:12 UTC
Permalink
Excellent extension :)
Thanks again for your help Tom.
Post by Tom Most
The View Source menu option displays the file as it was loaded from the
server--it does not reflect the changes made to the DOM by scripts. If
you want to view the source corresponding to the current DOM you can
select all (or just a portion) of the document, right click on the
selection, and hit "View Selection Source". If you find yourself using
this feature a lot then I recommend that you install the Firebug
extension--it's inspect feature gives you a live view of the DOM that
updates in real time, which can be very useful for observing the changes
scripts make.
--Tom
Post by +Ramin+
Thank you Tom. It worked.
Just one point: when I view the document with DOM inspector, the
attribute for 'onload' is set to empty but when I view the page source
(right click on the page, 'View Page Source') the attribute is not
changed... Do you know why?
Thanks,
-Ramin
Post by Tom Most
You want
document.body.setAttribute("onload", "");
--Tom
Post by +Ramin+
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);">
The body goes here...
</body>
</html>
--------- end HTML --
I need to parse this html with a greasemonky script so that I remove
-- begin HTML --------
<html>
<head> <title> Some Title </title> </head>
<body onLoad="">
The body goes here...
</body>
</html>
--------- end HTML --
-- begin JavaScript ------------------------
// ==UserScript==
// ==/UserScript==
function main()
{
document.documentElement.body.onLoad.value = "";
}
main();
--------------------- end JavaScript -----
Why is it not working?
Your help is appreciated :)
-Ramin
smime.p7s
4KDownload
smime.p7s
4KDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-***@googlegroups.com
To unsubscribe from this group, send email to greasemonkey-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...