本文主要介紹vue組件中使用iframe元素的範例程式碼,小編覺得挺不錯的,現在分享給大家,也給大家做個參考,希望能幫助到大家。
需要在本頁面中展示vue元件中的超鏈接,地址欄不改變的方法:
GoBack
需要使同層元素不被覆蓋,可以加
複製程式碼 程式碼如下:
#不過html5有新的dialog元素用於對話框。
iframe的一些方法:
取得iframe內容:
var iframe = document.getElementById("iframe1"); var iwindow = iframe.contentWindow; var idoc = iwindow.document; console.log("window",iwindow);//获取iframe的window对象 console.log("document",idoc); //获取iframe的document console.log("html",idoc.documentElement);//获取iframe的html console.log("head",idoc.head); //获取head console.log("body",idoc.body); //获取body
自適應iframe:
即1去掉捲軸,2設定寬高
var iwindow = iframe.contentWindow; var idoc = iwindow.document; iframe.height = idoc.body.offsetHeight;
範例:
相關推薦:
vue2.0資料雙向綁定與表單bootstrap+vue元件
以上是vue元件中使用iframe元素的方法範例的詳細內容。更多資訊請關注PHP中文網其他相關文章!