Home > Web Front-end > JS Tutorial > body text

How to use iframe elements in vue components

亚连
Release: 2018-06-20 18:26:52
Original
4346 people have browsed it

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:



Copy after login

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

Copy after login

, 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
Copy after login

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;
Copy after login

Example:

Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!