The code below (userJS code) simply create a link, and If click on that link, it pops up an alert.
It seems to work, but have a problem:
the alert associated with onclick event pops automatically when the page starts... I really don't know how it may happen...
I'm using FF, maybe it's a setting browser problem...
Here's the userJS code:
Thanks for help
P.s: As you can notice, I'm not referring to onClick javascript function,but to "onclick" event of DOM element.
Sacchi
It seems to work, but have a problem:
the alert associated with onclick event pops automatically when the page starts... I really don't know how it may happen...
I'm using FF, maybe it's a setting browser problem...
Here's the userJS code:
Code:
// ==UserScript==
// @name try
// @namespace [URL unfurl="true"]http://nosite.com[/URL]
// @description no description
// @include [URL unfurl="true"]http://www.indexmundi.com/*[/URL]
// ==/UserScript==
var temp = document.getElementsByTagName('BODY');
var linkz = document.createElement('A');
linkz.setAttribute('href', '[URL unfurl="true"]http://link.com');[/URL]
linkz.setAttribute('name', 'clickable link');
linkz.appendChild(document.createTextNode('This is the link'));
linkz.onclick = new Function(Do());
temp[0].appendChild(document.createElement('BR'));
temp[0].appendChild(document.createElement('BR'));
temp[0].appendChild(linkz);
function Do() {
alert('Hello!');
}
Thanks for help
P.s: As you can notice, I'm not referring to onClick javascript function,but to "onclick" event of DOM element.
Sacchi