美文网首页
js积累:模拟onclick触发,添加节点,iframe对象

js积累:模拟onclick触发,添加节点,iframe对象

作者: e8e976845a84 | 来源:发表于2019-12-03 09:53 被阅读0次

点滴知识来源于网络,当你提出问题的时候,答案已经出现

    //js 触发click

    //document.getElementById("LoadLayersTool").onclick();

    //添加元素到div下面

    //var div= document.getElementById("3DT1").contentWindow.document.getElementById("LoadLayersTool"); var div2 = document.createElement("button"); 

    //div2.innerText = "test"; div2.setAttribute('style', 'color:red;left:100px');

    //div2.setAttribute('onclick', 'test()'); div.appendChild(div2); function test() { alert("1234"); }

    //获取iframe里面的对象

    //var iframe = document.getElementById("xxx");//父窗口获取iframe子窗口对象

    //var iframew = iframe.contentWindow;//iframe窗口的window对象

    //var iframed = iframew.document;//iframe窗口的document对象

    //var iframed2 = iframe.contentDocument;//DOM2也支持直接获取document对象

相关文章

网友评论

      本文标题:js积累:模拟onclick触发,添加节点,iframe对象

      本文链接:https://www.haomeiwen.com/subject/fizqgctx.html