jQuery - 动态创建iframe并加载页面
<html>
<head>
<script language="JavaScript" src="jquery-1.11.1.min.js" type="text/javascript"></script>
<script language="JavaScript" type="text/JavaScript">
/**
弹出iframe页面(iframe后面会添加灰色蒙版)
**/
function showIframe(url,w,h){
//添加iframe
var if_w = w;
var if_h = h;
//allowTransparency='true' 设置背景透明
$("<iframe width='" + if_w + "' height='" + if_h + "' id='YuFrame1' name='YuFrame1' style='position:absolute;z-index:4;' frameborder='no' marginheight='0' marginwidth='0' allowTransparency='true'></iframe>").prependTo('body');
var st=document.documentElement.scrollTop|| document.body.scrollTop;//滚动条距顶部的距离
var sl=document.documentElement.scrollLeft|| document.body.scrollLeft;//滚动条距左边的距离
var ch=document.documentElement.clientHeight;//屏幕的高度
var cw=document.documentElement.clientWidth;//屏幕的宽度
var objH=$("#YuFrame1").height();//浮动对象的高度
var objW=$("#YuFrame1").width();//浮动对象的宽度
var objT=Number(st)+(Number(ch)-Number(objH))/2;
var objL=Number(sl)+(Number(cw)-Number(objW))/2;
$("#YuFrame1").css('left',objL);
$("#YuFrame1").css('top',objT); $("#YuFrame1").attr("src", url) //添加背景遮罩
$("<div id='YuFrame1Bg' style='background-color: Gray;display:block;z-index:3;position:absolute;left:0px;top:0px;filter:Alpha(Opacity=30);/* IE */-moz-opacity:0.4;/* Moz + FF */opacity: 0.4; '/>").prependTo('body');
var bgWidth = Math.max($("body").width(),cw);
var bgHeight = Math.max($("body").height(),ch);
$("#YuFrame1Bg").css({width:bgWidth,height:bgHeight}); //点击背景遮罩移除iframe和背景
$("#YuFrame1Bg").click(function() {
$("#YuFrame1").remove();
$("#YuFrame1Bg").remove();
});
}
</script>
</head>
<body>
<input type="button" onClick="showIframe('http://hangge.com',460,280)" value="加载"/>
</body>
<html>
jQuery - 动态创建iframe并加载页面的更多相关文章
- ExtJs非Iframe框架加载页面实现
在用Ext开发App应用时,一般的框架都是左边为菜单栏,中间为tab页方式的显示区域.而tab页面大多采用的嵌入一个iframe来显示内容.但是采用iframe方式有一个很大的弊端就是每次在加载一个新 ...
- 关于IE8中使用Jquery load方法无法正常加载页面
最近发现,在IE8中使用Jquery load方法时无法正常加载页面,页面显示空白,没有加载.调试发现,页面多了一个</div>标签,但在FF和CH下表现正常.希望能给遇到同样问题的码农有 ...
- jQuery load() 判断 iframe 是否加载完毕
判断 iframe 是否加载完毕 方法.jQuery load() var frm = document.getElementById('myiframe'); $(frm).load(functi ...
- jquery中的load方法加载页面无法缓存问题
在A页面中调用JQuery中的load方法,加载另一个B页面,B页面中的样式文件和JS文件无法从浏览器缓存中获取,每次都是实时获取.这是因为B页面的HTML经load方法处理后,会为每个样式和JS文件 ...
- javascript动态创建script标签,加载完成后调用回调
代码如下: var head = document.getElementsByTagName('head')[0]; var script = document.createElement('scri ...
- jquery load(URL,FUNCTION(){}) 异步加载页面
$("#btnSearch").click(function () { var queryUrl = '/Report/LoadInsClassifFileNew'; if ($( ...
- 解决pjax加载页面不执行js插件的问题
个人博客 地址:http://www.wenhaofan.com/article/20180913220425 介绍 在使用jquery.pjax的时候发现加载页面时不会执行其中的layui以及jqu ...
- jQuery EasyUI动态添加控件或者ajax加载页面后不能自动渲染问题的解决方法
博客分类: jquery-easyui jQueryAjax框架HTML 现象: AJAX返回的html无法做到自动渲染为EasyUI的样式.比如:class="easyui-layout ...
- 使用jquery的load方法设计动态加载,并解决被加载页面JavaScript失效问题
一.问题分析 对于后台系统,相比大家都有所印象,知道其中的布局结构,如图: 在这种布局中我们需要将header,sidebar,footer分开,而且对于中间部分的content内容需要动态变化,即根 ...
随机推荐
- UVALive 3989Ladies' Choice(稳定婚姻问题)
题目链接 题意:n个男生和女生,先是n行n个数,表示每一个女生对男生的好感值排序,然后是n行n列式每一个男生的好感值排序,输出N行,即每个女生在最好情况下的男生的编号 分析:如果是求女生的最好情况下, ...
- 利用Objective-C运行时hook函数的三种方法
版权声明:转载请注明出处:http://blog.csdn.net/hursing 方法一,hook已有公开头文件的类: 首先写一个Utility函数: #import <objc/runtim ...
- android studio中ListView与SQLite的结合使用
Da.java public class Db extends SQLiteOpenHelper { public Db(Context context) { super(context, " ...
- mysqli连接数据库的模板
<?php $host="localhost"; $db_user="root"; //数据库用户 $db_pass=""; //数据 ...
- 爬虫2 url管理器 url_manager.py
#coding:utf8 class UrlManager(object): def __init__(self): self.new_urls = set() self.old_urls = set ...
- coreseek 中文搜索和高亮
配置文件 # # Minimal Sphinx configuration sample (clean, simple, functional) # source post { type = mysq ...
- Linux下显示IP地理位置信息的小工具-nali
一.简介 nali,名字取自中文“哪里”的拼音.nali包含一组命令行程序,其主要功能就是把一些网络工具的输出的IP字符串,附加上地理位置信息(使用纯真数据库QQWry.Dat).例如74.125.1 ...
- ArcGIS Server 10.1 for Linux典型问题总结
关闭开启server服务: [gis@localhost ArcGISServer]$ cd /home/gis/arcgis/server [gis@localhost server]$ ./sto ...
- Spring MVC学习笔记——给Controller和视图传值
一.给Controller传值,值将显示在控制台 1.第一种:使用@RequestParam,改HelloController.java //RequestMapping表示用哪一个url来对应 @R ...
- R树空间索引及其变种
1.R树及其变种:百度百科 2.R树详介:http://blog.csdn.net/jazywoo123/article/details/7792745 3.R树及变种小结 R树:叶子节点或中间节点都 ...