An access element inside an iframe that sits inside a jQuery interface dialog

HTML is pretty simple, on my page I have

<div id="notificationDialog" title="View Notification"></div> 

I dynamically load notifications based on the user viewing the page and display them inside the iframe, which is inside the jQuery ui dialog box. Basically,

 function viewNotif(nid) { var wWidth = jQuery(window).width(); var dWidth = wWidth * 0.5; var $notifIframe = jQuery('<iframe />', { name: 'myFrame', id: 'myFrame', src: "/modals/modal_notification.php?nid="+nid, width:"100%", height:"100%", align:"center", scrolling:"auto", frameborder:"0" }); jQuery('#notificationDialog').html($notifIframe.clone()); jQuery('#notificationDialog').dialog({ autoOpen: false, height: auto, width: dWidth, modal: true }); jQuery('#notificationDialog').dialog('open'); } 

I am trying to access the div height value inside the iframe inside the jQuery ui dialog box and still have not been able to do this. How can I get the div height value, id of the div is the message_container which is inside the iframe, inside the Dialog notification?

EDIT - I should mention that the function is called in onClick on the page and passes the notification identifier (nid) for display to the function.

+4
source share
1 answer
 $("iframe").contents().find("#selector"); 

It should be noted that this is only permissible if the contents of the iframe are available locally. Otherwise, you will be denied access.

+3
source

All Articles