0

Could someone help me with this? I have a page sitting in an iframe in a window, to be more specific it is the SharePoint dialog box. I want to find an element with a specific id (or class, it doesn't matter) on the parent, not the window, where the popup originated.

I have tried

$(this).closest('.refreshbtn').click();
$(this).parents('.refreshbtn').click();
$(this).parent().parent().parent('.refreshbtn').click();

Tried it with javascript

window.parent.document.getElementById('refreshbtn').click();
window.parent.parent.document.getElementById('refreshbtn').click();

Without success.

Can someone shed some light?

Many thanks in advance.

  • It is true, thanks Barmer, it has been answered but I got it working just before viewing it... window.parent.document.getElementById was working but as I had set the ID of the element in question on page load the element lost the id when clicked. So here is my updated code: var refreshimg = window.parent.document.getElementById('ManualRefresh'); $(refreshimg).parent().closest('a').click(); – John Bellew Nov 18 '15 at 16:32

1 Answers1

1

try this in the iFrame

$('#refreshbtn', window.parent.document).on('click', function(){
//do something
}

or assign it to a variable

var button = $('#refreshbtn', window.parent.document);
nestedl00p
  • 490
  • 3
  • 14