实现网页背景变暗,显示信息提示效果!
2006-12-30 15:41
846 查看
<script language="javascript">
var alternateFrame=null;
var alternateWin=null;
window.alert=showAlert;
window.confirm=showConfirm;
function alternateWindow(){
this.win=null;
this.pBody=null;
this.pBg=null;
this.type="open";
this.FocusWhere="OK";
}
function showAlert(info){
alternateWin=new alternateWindow();
var pBody = alternateWin.init();
alternateWin.initAlertBody(pBody,info);
alternateWin.type="alert";
}
function showConfirm(info,ok_func,notok_func,ok_str,not_okstr){
alternateWin=new alternateWindow();
var pBody = alternateWin.init();
alternateWin.initConfirmBody(pBody,info,ok_func,notok_func,ok_str,not_okstr);
alternateWin.type="confirm";
}
alternateWindow.prototype.init=function(){
if(alternateFrame==null){
alternateFrame=document.createElement("<iframe allowTransparency='true' id='popframe' frameborder=0 marginheight=0 src='about:blank' marginwidth=0 hspace=0 vspace=0 scrolling=no></iframe>")
alternateFrame.style.position="absolute";
document.body.appendChild(alternateFrame);
}
else{
alternateFrame.style.visibility="visible";
}
alternateFrame.style.width=screen.availWidth;
alternateFrame.style.height=screen.availHeight;
alternateFrame.style.left=document.body.scrollLeft;
alternateFrame.style.top=document.body.scrollTop;
alternateFrame.name = alternateFrame.uniqueID;
this.win=window.frames[alternateFrame.name];
this.win.document.write("<body leftmargin=0 topmargin=0 oncontextmenu='self.event.returnValue=false'><div id=popbg></div><div id=popbody></div><div></div></body>");
this.win.document.body.style.backgroundColor="transparent";
document.body.style.overflow="hidden";
this.pBody=this.win.document.body.children[1];
this.pBg=this.win.document.body.children[0];
this.hideAllSelect();
this.initBg();
return this.pBody;
}
alternateWindow.prototype.initBg=function(){
with(this.pBg.style){
position="absolute";
left="0";
top="0";
width="100%";
height="100%";
visibility="hidden";
backgroundColor="#333333";
filter="blendTrans(duration=1) alpha(opacity=30)";
}
this.pBg.filters.blendTrans.apply();
this.pBg.style.visibility="visible";
this.pBg.filters.blendTrans.play();
}
alternateWindow.prototype.initAlertBody=function(obj,info){
with(obj.style){
position="absolute";
width="400";
height="150";
backgroundColor="#ffffff";
}
obj.style.left=window.document.body.clientWidth/2-200;
obj.style.top=window.document.body.clientHeight/3;
var str;
str ="<table border=0 cellpadding=0 cellspacing=1 bgcolor=#000000 width=100% height=100%><form id='form1' name='form1'><tr height=30>";
str+="<td align=left style='color:#000000;font-size:14px;font-weight:bold' bgcolor=#9999ff>[提示]</td></tr>";
str+="<tr><td align=center bgcolor=#efefff style='font-size:12px;color:#000000;vertical-align: middle;'>";
str+=info+"<input type=text id=ttt><input type=text id=rrr><input type=text id=uuu><input type='button' onclick='alert(this.name);parent.getall();' value='传递文字'></td></tr><tr height=30 bgcolor=#efefef><td align=center>" +
"<input type='button' value='确定' id='OK'" +
" onkeydown='parent.alternateWin.onKeyDown(event,this)'"+
" onclick='parent.alternateWin.closeWin()' style='border:solid 1px #666666;background:#cccccc'>" +
"</td></tr></form></table>";
obj.innerHTML=str;
this.win.document.body.all.OK.focus();
this.FocusWhere="OK";
}
alternateWindow.prototype.onKeyDown=function(event,obj){
switch(event.keyCode){
case 9:
event.keyCode=-1;
if(this.type=="confirm"){
if(this.FocusWhere=="OK"){
this.win.document.body.all.NO.focus();
this.FocusWhere="NO";
}
else{
this.win.document.body.all.OK.focus();
this.FocusWhere="OK";
}
}
break;
case 13:obj.click();;
break;
case 27:this.closeWin();
break;
}
}
alternateWindow.prototype.closeWin=function(){
alternateFrame.style.visibility="hidden";
this.showAllSelect();
document.body.style.overflow="auto";
}
alternateWindow.prototype.hideAllSelect=function(){
var obj;
obj=document.getElementsByTagName("SELECT");
var i;
for(i=0;i<obj.length;i++)
obj[i].style.visibility="hidden";
}
alternateWindow.prototype.showAllSelect=function(){
var obj;
obj=document.getElementsByTagName("SELECT");
var i;
for(i=0;i<obj.length;i++)
obj[i].style.visibility="visible";
}
function formToRequestString(formname){
var query_string='';
var form_obj = window.frames[0].document.getElementById(formname).elements;
for (var i=0;i<form_obj.length ;i++){
var e=form_obj[i];
if (e.id!=''){
var element_value = "";
if (e.type.toLowerCase()=='select'){
element_value=e.options[e.selectedIndex].value;
}
else if (e.type.toLowerCase()=='checkbox' || e.type.toLowerCase()=='radio'){
if (e.checked==false){
continue;
}
element_value=e.value;
}
else{
element_value=e.value;
}
query_string+=e.name+'='+element_value.replace(/&/g,"%26") + '&';
}
}
return query_string;
}
</script>
<script>
function getall() {
document.getElementById("ssss").value = window.frames[0].document.getElementById("ttt").value;
}
</script>
<input name=ssss type=text>
<div id=naeee>
</div>
<body>
<button onclick="alert('');">
跳出新窗口传值
</button>
</body>
var alternateFrame=null;
var alternateWin=null;
window.alert=showAlert;
window.confirm=showConfirm;
function alternateWindow(){
this.win=null;
this.pBody=null;
this.pBg=null;
this.type="open";
this.FocusWhere="OK";
}
function showAlert(info){
alternateWin=new alternateWindow();
var pBody = alternateWin.init();
alternateWin.initAlertBody(pBody,info);
alternateWin.type="alert";
}
function showConfirm(info,ok_func,notok_func,ok_str,not_okstr){
alternateWin=new alternateWindow();
var pBody = alternateWin.init();
alternateWin.initConfirmBody(pBody,info,ok_func,notok_func,ok_str,not_okstr);
alternateWin.type="confirm";
}
alternateWindow.prototype.init=function(){
if(alternateFrame==null){
alternateFrame=document.createElement("<iframe allowTransparency='true' id='popframe' frameborder=0 marginheight=0 src='about:blank' marginwidth=0 hspace=0 vspace=0 scrolling=no></iframe>")
alternateFrame.style.position="absolute";
document.body.appendChild(alternateFrame);
}
else{
alternateFrame.style.visibility="visible";
}
alternateFrame.style.width=screen.availWidth;
alternateFrame.style.height=screen.availHeight;
alternateFrame.style.left=document.body.scrollLeft;
alternateFrame.style.top=document.body.scrollTop;
alternateFrame.name = alternateFrame.uniqueID;
this.win=window.frames[alternateFrame.name];
this.win.document.write("<body leftmargin=0 topmargin=0 oncontextmenu='self.event.returnValue=false'><div id=popbg></div><div id=popbody></div><div></div></body>");
this.win.document.body.style.backgroundColor="transparent";
document.body.style.overflow="hidden";
this.pBody=this.win.document.body.children[1];
this.pBg=this.win.document.body.children[0];
this.hideAllSelect();
this.initBg();
return this.pBody;
}
alternateWindow.prototype.initBg=function(){
with(this.pBg.style){
position="absolute";
left="0";
top="0";
width="100%";
height="100%";
visibility="hidden";
backgroundColor="#333333";
filter="blendTrans(duration=1) alpha(opacity=30)";
}
this.pBg.filters.blendTrans.apply();
this.pBg.style.visibility="visible";
this.pBg.filters.blendTrans.play();
}
alternateWindow.prototype.initAlertBody=function(obj,info){
with(obj.style){
position="absolute";
width="400";
height="150";
backgroundColor="#ffffff";
}
obj.style.left=window.document.body.clientWidth/2-200;
obj.style.top=window.document.body.clientHeight/3;
var str;
str ="<table border=0 cellpadding=0 cellspacing=1 bgcolor=#000000 width=100% height=100%><form id='form1' name='form1'><tr height=30>";
str+="<td align=left style='color:#000000;font-size:14px;font-weight:bold' bgcolor=#9999ff>[提示]</td></tr>";
str+="<tr><td align=center bgcolor=#efefff style='font-size:12px;color:#000000;vertical-align: middle;'>";
str+=info+"<input type=text id=ttt><input type=text id=rrr><input type=text id=uuu><input type='button' onclick='alert(this.name);parent.getall();' value='传递文字'></td></tr><tr height=30 bgcolor=#efefef><td align=center>" +
"<input type='button' value='确定' id='OK'" +
" onkeydown='parent.alternateWin.onKeyDown(event,this)'"+
" onclick='parent.alternateWin.closeWin()' style='border:solid 1px #666666;background:#cccccc'>" +
"</td></tr></form></table>";
obj.innerHTML=str;
this.win.document.body.all.OK.focus();
this.FocusWhere="OK";
}
alternateWindow.prototype.onKeyDown=function(event,obj){
switch(event.keyCode){
case 9:
event.keyCode=-1;
if(this.type=="confirm"){
if(this.FocusWhere=="OK"){
this.win.document.body.all.NO.focus();
this.FocusWhere="NO";
}
else{
this.win.document.body.all.OK.focus();
this.FocusWhere="OK";
}
}
break;
case 13:obj.click();;
break;
case 27:this.closeWin();
break;
}
}
alternateWindow.prototype.closeWin=function(){
alternateFrame.style.visibility="hidden";
this.showAllSelect();
document.body.style.overflow="auto";
}
alternateWindow.prototype.hideAllSelect=function(){
var obj;
obj=document.getElementsByTagName("SELECT");
var i;
for(i=0;i<obj.length;i++)
obj[i].style.visibility="hidden";
}
alternateWindow.prototype.showAllSelect=function(){
var obj;
obj=document.getElementsByTagName("SELECT");
var i;
for(i=0;i<obj.length;i++)
obj[i].style.visibility="visible";
}
function formToRequestString(formname){
var query_string='';
var form_obj = window.frames[0].document.getElementById(formname).elements;
for (var i=0;i<form_obj.length ;i++){
var e=form_obj[i];
if (e.id!=''){
var element_value = "";
if (e.type.toLowerCase()=='select'){
element_value=e.options[e.selectedIndex].value;
}
else if (e.type.toLowerCase()=='checkbox' || e.type.toLowerCase()=='radio'){
if (e.checked==false){
continue;
}
element_value=e.value;
}
else{
element_value=e.value;
}
query_string+=e.name+'='+element_value.replace(/&/g,"%26") + '&';
}
}
return query_string;
}
</script>
<script>
function getall() {
document.getElementById("ssss").value = window.frames[0].document.getElementById("ttt").value;
}
</script>
<input name=ssss type=text>
<div id=naeee>
</div>
<body>
<button onclick="alert('');">
跳出新窗口传值
</button>
</body>
相关文章推荐
- 实现网页背景变暗,显示信息提示效果!
- Ueditor编辑保存的内容网页显示时背景等信息无效果---参考UEditor官方文档之编辑内容展示
- 137在搜索框中实现下拉列表效果(扩展知识:表格视图数据源为空数据时显示提示信息)
- Jquery实现Mouseover显示跟随的提示信息效果
- Ueditor编辑保存的内容网页显示时背景等信息无效果---参考UEditor官方文档之编辑内容展示
- 巧使网页图片实现“幻灯片”显示效果
- JS实现仿新浪信息提示效果
- C#之使用NotifyIcon实现任务栏托盘菜单,图标闪烁效果及气泡提示 很多程序是只需要后台运行的,甚至不需要自己的应用界面。NotifyIcon提供了程序在任务栏的显示功能 程序下载链接如下
- CSS实现网页背景颜色渐变的效果。
- div 上显示提示层效果 jquery实现
- 实现http://www.wandoujia.com/中的鼠标悬停显示详细信息效果
- 非常不错的一款连接提示信息显示效果
- MFC中通过Tooltip类来实现悬浮鼠标显示提示信息
- Android实现PopupWindow 弹窗效果 可用于提示信息等
- 实现联系人列表滑动显示提示信息 以及弹出选择菜单
- 一个不错的可拖动层遮罩加ALPHA滤镜(点击弹出后背景变浅色,信息提示框效果)
- jQuery实现鼠标经过弹出提示信息的地图热点效果
- gridview中把字段超出范围的用...代替 但前台文本提示效果需显示详细信息
- 基于jquery实现漂亮的动态信息提示效果
- jquery实现在网页指定区域显示自定义右键菜单效果