Lấy get data-width & data-height Outside iframe javascript jQuery JS Mình có cái Iframe, lúc gọi nó trong file js truyền từ web chính sang các web con. Mình không thể lấy data-width & data-height của nó được. Bạn nào biết cách lấy giúp mình với. Ở View chèn Iframe code như sau: HTML: <div id="ifimgqc" data-width="230" data-height="320"></div><script type="text/javascript" src="http://webcuaminh/jsiframe.js"></script> Code file jsiframe.js của mình là: HTML: var ifrm = document.createElement("iframe"); ifrm.id = "iframeimg"; ifrm.setAttribute("src", "http://...."); ifrm.style.height:.. ifrm.style.width:.. ............ Làm sao ở trong jsiframe.js mình có thể lấy được data-width="230" data-height="320" giúp mình với.
Code của bạn đây: Mã: var getifid = window.parent.document.getElementById('ifimgqc'); var dtwidth = getifid.getAttribute('data-width'); var dtheight = getifid.getAttribute('data-height');