I'm trying to add a script that will display confirm dialog asking
"Leave the page?" when user clicks on any link.
I'm using FF 4.0 and Greasemonkey 0.9.1.
Script below doesn't work
// ==UserScript==
// @name Test
// @namespace abc
// @description None
// @include *
// ==/UserScript==
var m = "Leave the page?";
var an = document.getElementsByTagName("a");
for (a = 0; a < an.length; a++) {
an[a].onclick = function () { return confirm(m); }
}
Following doesn't work either:
window.onload = load;
function load()
{
var m = "Leave the page?";
var an = document.getElementsByTagName("a");
for (a = 0; a < an.length; a++) {
an[a].onclick = function () { return confirm(m); }
}
}
but it works as a custom javascript (without greasemonkey)
Can somebody please help me with the code?
Thanks
--
You received this message because you are subscribed to the Google Groups
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/greasemonkey-users?hl=en.