H5_0030:iframe 全屏嵌入,父级获取iframe中嵌入的dom对象

            var i = document.getElementById("popup");
            if (this.link) {
                g_currentHot = this, i.style.display = "block", i.classList.add("wait");
                var n = document.createElement("iframe");
                g_bgAudio && g_bgAudio.pause();
                // console.log(this.link);
                //热点点击方法
                var r = this.link.substring(this.link.indexOf("html") + 4),
                    o = "en" == manage.number("lang") ? "&lang=" + manage.number("lang") : "";
                     - 1 == r.indexOf("?") ? n.src = this.link + "?time=" + randomTime().getTime() + "&id=" + window.number + o : 
                     n.src = this.link + "&time=" + randomTime().getTime() + "&id=" + window.number + o, n.id = "id1", 
                     n.allowTransparency = "true";

                var a = document.getElementById("id1");
                // console.log(r);
                if (void 0 === a || null == a) {
                    document.querySelector(".popup-content").appendChild(n);
                    var s = !1;
                    window.loaddingSuccess = function() {
                        s = !0
                    }, setTimeout(function e() {
                        if (s) {
                            //得到iframe对象后,就可以通过contentWindow得到iframe包含页面的window对象,然后就可以正常访问页面元素了;
                            var t = document.querySelector("#id1").contentWindow.document;
                            t.querySelector("video") && (t.querySelector("video").play(), 
                            !t.querySelector("video").paused && t.querySelector(".playPause") && t.querySelector(".playPause").classList.add("fa-pause")), 
                            t.querySelector("audio") && t.querySelector("audio").play()
                        } else setTimeout(e, 300)
                    }, 800)
                }
            }
琥珀君的博客
原文地址:https://www.cnblogs.com/eliteboy/p/12439176.html