vue iframe嵌套页面高度自适应 (ios 宽度扩大的bug , ios展示比例问题)

<template>

<div class="card-index pt-relative">

<div id="wrapper" :style="‘height:‘+Height+‘px;‘">

<iframe

v-if="iframeType"

:src="srcUrl"

sandbox="allow-forms allow-same-origin allow-scripts allow-top-navigation allow-modals"

id="iframe"

marginwidth="0"

marginheight="0"

align="center"

></iframe>

<iframe

v-else

:src="srcUrl"

sandbox="allow-forms allow-same-origin allow-scripts allow-top-navigation allow-modals"

id="iframe"

scrolling="no"

marginwidth="0"

marginheight="0"

align="center"

></iframe>

</div>

</div>

</template>

data() {

return {

srcUrl: "",

iframeType: false

};

},

created() {

var u = navigator.userAgent;

var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android终端

// var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端

// console.log(‘是否是Android:‘+isAndroid);

// console.log(‘是否是iOS:‘+isiOS);

if (isAndroid) {

this.iframeType = true;

} else {

this.iframeType = false;

}

}

<style lang=‘scss‘ scoped>

.card-index /deep/ {

width: 100%;

position: relative;

#iframe {

width: 100%;

height: 100%;

overflow: scroll;

-webkit-overflow-scrolling: touch;

min-width: 100%;

*width: 100%;

width: 1px;

}

#wrapper {

-webkit-overflow-scrolling: touch;

overflow: auto;

position: fixed;

right: 0;

left: 0;

top: 0;

bottom: 0;

width: 100%;

height: 100%;

}

</style>

原文地址:https://www.cnblogs.com/FACESCORE/p/11990919.html

时间: 2024-08-30 07:00:42

vue iframe嵌套页面高度自适应 (ios 宽度扩大的bug , ios展示比例问题)的相关文章

Vue. 之 Element table 高度自适应

Vue. 之 Element table 高度自适应 使用vue创建table后,其高度自适应浏览器高度. 在创建的 el-table 中添加:height属性,其值为一个变量(tableHeight) 1 <el-table 2 :data="tableData" 3 :height="tableHeight" 4 border 5 style="width: 100%"> 在script中的data() 中添加高度的定义: 这里的

vue中嵌套页面 iframe 标签

vue中嵌套iframe,将要嵌套的文件放在static下面: <iframe src="../../../static/bear.html" width="300" height="300" frameborder="0" scrolling="auto"></iframe> src可以使用相对路径,也可使用服务器根路径http:localhost:8088/-等: <ifr

解决Iframe跨域高度自适应,利用window.postMessage()实现跨域消息传递页面高度(JavaScript)

在iframe跨域引用高度自适应这块写的js方式都试了不管用,最终使用的是window.postMessage() 跨域获取高度 传递信息 1.首先,在主页面上使用iframe引入子页面:也就是A.html页面引入B.html页面,下面看看A.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head>

完美实现跨域Iframe高度自适应【Iframe跨域高度自适应解决方案】

Iframe的强大功能偶就不多说了,它不但被开发人员经常运用,而且黑客们也常常使用它,总之用过的人知道它的强大之处,但是Iframe有个致命的“BUG”就是iframe的高度无法自动适应,这一点让很多人都头疼万分.百度或是谷歌一下,确实很多解决方法,但尝试一下,会发现问题很多:浏览器兼容性差,不能自适应,仅支持同域Iframe等诸多问题,尤其是跨域Iframe高度自适应问题.网上根本找不到一种可行的方案(唯一有一种提到加入代理页面的,经过测试发现无用).难道真的没有一种可行的解决方案了吗? No

iframe嵌套页面中的跳转

简单说一下场景. 假设有A.B.C和D四个JSP页面,D通过iframe嵌套在C中,C通过iframe嵌套在B中,B通过iframe嵌套在A中. 然后现在在D中编写JavaScript代码跳转页面. 在本页面跳转(D页面所在的iframe中跳转) window.location.href = '要跳转的页面路径'; 在上一层跳转(D页面所在iframe的父页面中跳转,即C所在的iframe中跳转) parent.location.href = '要跳转的页面路径'; 如果要在B所在的iframe

页面高度自适应方法(PC、移动端都适用)

有个项目移动端的首页需要自适应. 宽度已经自适应了 , 高度也要自适应 ,先总结一下方法,PC端也适用. $(function(){ var h = window.innerHeight; $(".carousel-inner>.item>a>img, .carousel-inner>.item>img, .img-responsive, .thumbnail a>img, .thumbnail>img").css("height&q

iframe标签父页面高度自适应

注意:页面html节点上要有 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <iframe id="mainFrame" name="mainFrame" scrolling="no" src=

html页面高度自适应

本文实现的效果是根据浏览器分辨率的不同,页面底端背景色自适应浏览器高度,也就是可以自动填充背景色. <script type="text/javascript"> function height_adaptive(){ var main=$(document).height(); var title=document.getElementById("login_title").scrollHeight; var body=document.getElem

关于使用iframe嵌套页面的跳转方式

一.背景A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,在D中跳转页面的写法区别如下. 二.JS跳转window.location.href.location.href 本页面跳转,D页面跳转 parent.location.href 上一层页面跳转,C页面跳转 top.location.href 最外层页面跳转,A页面跳转 三.链接或者formD页面中有form <form>: form提交后D页面跳转 <form target="