html代码
<iframe id="iframepage" width="100%" src="$url" frameborder='no' scrolling="yes" allowtransparency="yes" >
frameborder=yes|no 是否显示框架边框
allowtransparency=yes|no 是否显示滚动条
JS代码
js宽度高度自适应
function changeFrameHeight(){
var ifm= document.getElementById("iframepage");
var height =ifm.height=document.documentElement.clientHeight;
var width = ifm.width=document.documentElement.clientWidth;
}
window.onload = window.onresize=function(){
changeFrameHeight();
}
// 判断是否是PC端
function IsPC() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone","SymbianOS", "Windows Phone","iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}
判断是否是手机端还是PC端:https://www.cnblogs.com/zhuchenglin/p/7528250.html
网友评论