Simulate click inside iframe with JavaScript or jQuery -


this question has answer here:

i have html containing iframe , 2 buttons, master , slave. slave displays "clicked" upon being clicked on while master simulates clicking action. works fine, i'd same behavior applied slave inside iframe. possible achieve such functionality? current code ignores iframe.

    $(document).ready(function() {           $('#master').click(function() {             simulateclick(50, 50); //iframe position             simulateclick(50, 100); //slave position         });         $('#slave').click(function() {             alert('clicked');         });     });      function simulateclick(x, y) {         jquery(document.elementfrompoint(x, y)).click();     } 

the document ready function not guarantee iframe has loaded. guess running before iframe has loaded. try like:

    $(document).ready(function () {      $('#iframeid').load(function () {        $('#master').click(function() {             simulateclick(50, 50); //iframe position             simulateclick(50, 100); //slave position         });         $('#slave').click(function() {             alert('clicked');         });     }); }); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -