博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一个JS对话框,可以显示其它页面,
阅读量:6981 次
发布时间:2019-06-27

本文共 2672 字,大约阅读时间需要 8 分钟。

还不能自适应大小

garyBox.js

// JavaScript Document // gary 2014-3-27 // 加了 px 在google浏览器没加这个发现设置width 和height没有用 //gary 2014-3-27//实在不会用那些JS框架,自己弄个,我只是想要个可以加载其它页面的对话框而以,这里用了别人的代码,不过不记得来源了//关闭那两个字可能乱码,自己另存下,这个是utf8没问题//调用/////弹窗 ///var garyBox ;var garyBoxHead;var garyBoxTitleText;var garyBoxClose;var garyBoxIframe;function createGaryBox(){document.body.innerHTML+="

title

关闭

"; garyBox = document.getElementById("garyBox"); garyBox.style.cssText="border:1px solid #369;width:400px;height:250px;background:#e2ecf5;z-index:1000;position:absolute;display:none;"; garyBoxHead=document.getElementById("garyBoxHead"); garyBoxHead.style.cssText="height:20px;background:#369;color:#fff;padding:5px 0 0 5px;"; garyBoxTitleText=document.getElementById("garyBoxTitleText"); garyBoxTitleText.style.cssText="float:left;"; garyBoxClose = document.getElementById("garyBoxClose"); garyBoxClose.style.cssText="cursor:pointer;float:right; margin-right:10px;"; garyBoxIframe=document.getElementById("garyBoxIframe"); } function showGaryBox(title,url,onClose,width,height){ if(!garyBox)createGaryBox(); if(!arguments[3]) width = 600; if(!arguments[4]) height = 300; garyBoxTitleText.innerHTML=title;
garyBox.style.display = "block"; garyBox.style.position = "absolute"; garyBox.style.top = "50%"; garyBox.style.left = "50%"; garyBox.style.marginTop = (-height/2)+"px"; garyBox.style.marginLeft = (-width/2)+"px"; garyBox.style.width=width+'px'; garyBox.style.height=height+'px'; garyBoxIframe.style.width=garyBox.style.width; garyBoxIframe.style.height=garyBox.style.height; var garyBoxBg = document.createElement("div"); garyBoxBg.setAttribute("id","garyBoxBg"); garyBoxBg.style.background = "#000"; garyBoxBg.style.width = "100%"; garyBoxBg.style.height = "100%"; garyBoxBg.style.position = "absolute"; garyBoxBg.style.top = "0"; garyBoxBg.style.left = "0"; garyBoxBg.style.zIndex = "500"; garyBoxBg.style.opacity = "0.3"; garyBoxBg.style.filter = "Alpha(opacity=30)"; document.body.appendChild(garyBoxBg); document.body.style.overflow = "hidden"; garyBoxClose.onclick = function() { garyBox.style.display = "none"; garyBoxBg.style.display = "none"; if(onClose) { onClose(); } } garyBoxIframe.style.margin=0; garyBoxIframe.style.padding=0; garyBoxIframe.src=url; garyBoxIframe.onload=function(){ }}

 

转载于:https://www.cnblogs.com/meieiem/p/3627986.html

你可能感兴趣的文章
怎样与人沟通?
查看>>
SQL Server插入中文数据后出现乱码
查看>>
Javascript 思维导图
查看>>
转:Ogre的MaterialSystem分析
查看>>
EmberJS路由详解
查看>>
程序员如何缓解“电脑病”
查看>>
MSSQL WITH (NOLOCK) 脏读
查看>>
Android 动画之ScaleAnimation应用详解
查看>>
充满想象力的 JavaScript 物理和重力实验
查看>>
android中OnItemClickListener的参数解释
查看>>
最简单的视音频播放示例9:SDL2播放PCM
查看>>
sprintf,你知道多少?
查看>>
Eclipse中SVN的安装步骤(两种)和用法
查看>>
【转】一篇文章读懂人力资源三支柱体系(COE・BP・SSC)
查看>>
Java反射,参数为数组
查看>>
LDAP实例异常停止日志提示虚拟内存virtual memory不足
查看>>
Asp.Net MVC 3【URLs, Routing,and Areas】续
查看>>
我的Objective-C系列文章
查看>>
Linux学习之六-Yum命令的使用
查看>>
SQL 把表中字段存储的逗号隔开内容转换成列表形式
查看>>