javascript - Iframe inside Iframe cant do changes -
i have 1 iframe within on iframe , code want alter src of image
window.top.frames[0].frames[0].document.getelementbyid("maquina").src = "https://developer.cdn.mozilla.net/media/img/mdn-logo-sm.png";
and when seek it work cant see changes in page, in code when e read .src of element
you cannot manipulate contents of iframe within parent frame without global method accessing kid dom. there reply here suits needs, re-create below reference:
in kid iframe:
parent.childgetelementbyid = function (id) {return document.getelementbyid(id);} parent.childloaded();
in parent:
function childloaded() {var dom = childgetelementbyid('someid');}
assuming have access kid page, recommend modifying design away utilize of iframes.
[answering comment]
well depends on if you're using straight html, or scripting language (like php). if pure html, can utilize server side includes
<!-- #include virtual="path/to/included/file.html" -->
in php, can include page
require('/real/path/to/included/file.php');
don't me wrong, iframes can useful in specific situations (circumventing cross-domain origin policies, oauth implementations, etc); more abused correctly used.
javascript
No comments:
Post a Comment