实现网页背景变暗,显示信息提示效果!

< 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 οncοntextmenu='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' οnclick='alert(this.name);parent.getall();' value='传递文字'></td></tr><tr height=30 bgcolor=#efefef><td align=center> "   +
    
" <input type='button' value='确定' id='OK' "   +
    
"  οnkeydοwn='parent.alternateWin.onKeyDown(event,this)' " +
    
"  οnclick='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 >
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Android 中,可以通过设置 Dialog 或 PopupWindow 的背景实现弹窗背景变暗效果。具体实现步骤如下: 1. 创建一个布局文件,用于定义 Dialog 或 PopupWindow 的界面。可以在布局文件中添加一个全屏的半透明背景,用于实现背景变暗效果。 2. 在代码中创建 Dialog 或 PopupWindow 对象,并将上面创建的布局文件设置为其内容。 3. 为 Dialog 或 PopupWindow 设置背景。可以使用 ColorDrawable、GradientDrawable 或者其他类型的 Drawable 来设置背景。在设置背景时,可以使用半透明的颜色来实现背景变暗效果。 4. 显示 Dialog 或 PopupWindow。 下面是一个示例代码,用于实现弹窗背景变暗效果: ```java // 创建一个用于定义弹窗界面的布局文件 View popupView = LayoutInflater.from(context).inflate(R.layout.popup_layout, null); // 创建 PopupWindow 对象 PopupWindow popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); // 设置背景 ColorDrawable background = new ColorDrawable(Color.parseColor("#80000000")); popupWindow.setBackgroundDrawable(background); // 显示 PopupWindow popupWindow.showAtLocation(parentView, Gravity.CENTER, 0, 0); ``` 在上面的代码中,我们创建了一个 PopupWindow 对象,并将一个布局文件设置为其内容。然后,我们使用 ColorDrawable 来创建一个半透明的背景,并将其设置为 PopupWindow 的背景。最后,我们显示 PopupWindow。这样,当弹窗显示时,背景变暗,以突出弹窗。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值