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

Example of how to use iframe elements in vue components

小云云
Release: 2018-05-15 11:34:29
Original
6181 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 you a reference. I hope it can help everyone.

You need to display the hyperlink in the vue component on this page, and the address bar does not change:



Copy after login

If you need to prevent the elements of the same layer from being overwritten, you can add

Copy code The code is as follows:


But html5 has a new dialog element for dialogue frame.

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

Related recommendations:

Detailed explanation of the three writing forms of vue components

How to publish vue components To npm

vue2.0 data two-way binding with form bootstrap+vue component

The above is the detailed content of Example 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 admin@php.cn
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!