Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

click event does not work with popupModal

Status
Not open for further replies.

new2JS

Programmer
May 18, 2011
2
US
I am writing an add-on to parse/control one of the web-page that I am visiting regularly. Here is the snippet of code from the web-site:

-------------
<div aria-labelledby="ui-dialog-title-popupModal" role="dialog" tabindex="-1" class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable" style="display: block; z-index: 1002; outline: 0px none; position: absolute; height: auto; width: 200px; top: 124px; left: 127px;">
<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
<span id="ui-dialog-title-popupModal" class="ui-dialog- title">
User Message
</span>
<a role="button" class="ui-dialog-titlebar-close ui-corner-all" href="#">
<span class="ui-icon ui-icon-closethick">
close
</span>
</a>
</div>

<div class="ui-dialog-content ui-widget-content" id="popupModal" style="width: auto; min-height: 72.1px; height: auto;">
<strong>
Your Message is Successfully Accepted
</strong>
<br>
<br>
<div style="float: right; margin-top: 10px;">
<input value="Close" onclick='$("#popupModal").dialog( "close" );' type="button">
</div>
</div>
</div>
-------------


======
I am trying to write a add-on that will automatically click on the Button element said above. Here is my JS code in the add-on:

-------------
var tabDoc = window.opener.gBrowser.getBrowserAtIndex(0).contentDocument;
var pop_ok = tabDoc.getElementById("popupModal").getElementsByTagName('input')[0];
if (pop_ok) {
var clkevt = tabDoc.createEvent("MouseEvents");
clkevt.initEvent("dblclick",true,true);
pop_ok.dispatchEvent(clkevt);
}
-------------

But it does not close the popupModal alert automatically. I could see that it finds an button object and goes inside "if (pop_ok)" condition. But it does not trigger the button event. I tried both "click" and "dblclick", but without success.

Can I get some help here to understand what's going on and why click event does not close the popupModal alert?
I am new to JS, so please....please.... help.

Thanks in advance.
 
Can anyone help me to resolve above issue???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top