Nikola Topalovic Nikola Topalovic - 1 year ago 101
jQuery Question

Select table td value inside iframe with jquery

I am trying to do this for an hours. I have found may suggestions here and there and none of them work.

<button id="dugme" type="button">Click Me!</button>

<iframe id="frm" src="" width="260px" height="130px" frameborder="0" scrolling="no"></iframe>

this is what I have inside my wordpress page.
I know iframe is its own DOM or something like that and I tried a lot of suggestions I found online but non of them work.

Last thing I tried was this:

jQuery(document).ready(function($) {
var target_document = $('#frm')[0].contentWindow.document;
var target_result = $(target_document).find('table');
$('#dugme').on('click', function() {


Can anybody help me with this, please?

Answer Source

You will have no luck modern browsers recognize this for a good reason as Cross Site Scripting.

Imagine you go on a page of an author and in an invisible iframe the author buys 20 books on amazon for you. Just via jscript clicks and because you are logged in to amazon on another tab.