javascript - How to get an element from an iframe -


i want element iframe using javascript. i've tried following:

var iframe = document.getelementbyid("iframe id");

var iframewindow = iframe.contentwindow || iframe.contentdocument.parentwindow;

 iframe.onload = function(){           alert(iframewindow.getelementbyid('notice'));      }; 

can me working?

with cross domain

thanks reply

assuming on same domain;

var ifr = document.getelementbyid('the_iframes_id'); //or window.frames[x]. var doc = ifr.contentdocument || ifr.contentwindow.document; alert(doc.getelementbyid('notice')); 

if not on same domain, cannot access security reasons.


Comments