ddlam
asked on
document.links cannot trigger onClick in Firefox
Oh, let say I am tracing a Facebook application.
I have some hyperlink do not show in document.links[]
I tried to setTimeout() for 5 seconds and retrieve the tree again. The hyperlinks still absent.
So I tried other way, I make a newLink with a onClick function and use document.appendChild(newLi nk) to append it.
However, I don't know how to trigger onClick since it doesn't show in the document.links[].click
The newLink can add anything but how can I trigger its onClick event????
I have some hyperlink do not show in document.links[]
I tried to setTimeout() for 5 seconds and retrieve the tree again. The hyperlinks still absent.
So I tried other way, I make a newLink with a onClick function and use document.appendChild(newLi
However, I don't know how to trigger onClick since it doesn't show in the document.links[].click
The newLink can add anything but how can I trigger its onClick event????
var yourform = document.getElementById("app1");
var newLink=document.createElement('a');
var pickText=document.createTextNode('text for new link');
newLink.setAttribute('onclick',"fbjs_sandbox.instances.a17326627347.bootstrap();");
newLink.setAttribute('id','linkID');
newLink.appendChild(pickText);
yourform .appendChild(newLink);
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks third and scrathcyboy, how come facebook know this tricky thing.
I am trying to use simulateClick(). Hope it can find the mouse event.
I am trying to use simulateClick(). Hope it can find the mouse event.
function simulateClick() {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
var cb = document.getElementById("checkbox");
var canceled = !cb.dispatchEvent(evt);
if(canceled) {
// A handler called preventDefault
alert("canceled");
} else {
// None of the handlers called preventDefault
alert("not canceled");
}
}
ASKER
Yup, MouseEvents works~!
I don't know that I helped any more than third did. You might want to split points with him at least.
Open in new window