Home  >  Article  >  Web Front-end  >  How to use iframe elements in vue components

How to use iframe elements in vue components

亚连
亚连Original
2018-06-20 18:26:524355browse

This article mainly introduces the sample code for using iframe elements in vue components. The editor thinks it is quite good. Now I will share it with you and give it as a reference. Let’s follow the editor and take a look.

This article introduces the sample code for using iframe elements in the vue component and shares it with everyone. The details are as follows:

Need to display the vue component in this page Methods to keep hyperlinks and address bars from changing:



You need to prevent elements at the same level from being overwritten. You can add

, but HTML5 has a new dialog element for dialog boxes.

Some methods of iframe:

Get iframe content:

 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

Adaptive iframe:

That is, 1 remove the scroll bar, 2 set the width and height

var iwindow = iframe.contentWindow;
var idoc = iwindow.document;
iframe.height = idoc.body.offsetHeight;

Example:

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to implement Tuya in WeChat applet

Detailed explanation of how to use parent components "outside" React components

Detailed interpretation of the iterable protocol in ES6 syntax

The above is the detailed content of How to use iframe elements in vue components. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn