js锁屏,改进前一个仿弹出窗口

对前一个js仿弹出的改过,效果不错,可以在IE,FF,chrome正常^-^


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Author" CONTENT="strouven">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY><script>
  function create(str){
         window.scrollTo(0,0);

	var bordercolor="#336699";
	var bg=document.createElement('div');
	bg.setAttribute('id','boxs1');
	bg.style.position='absolute';
	bg.style.zIndex='0';
	bg.style.top='0px';
	bg.style.left='0px';
	bg.style.background='#000000';	
	bg.style.opacity='0.5';
	bg.style.filter='alpha(Opacity=50)';
	bg.style.width = getWidth()+'px';
	bg.style.height = getHeight()+'px';
    bg.style.display = 'block';
    bg.style.display = 'block';
	bg.style.color='#fff';
	//bg.innerHTML='<div align=\'center\'>sdjfsadjflksdjflsdjsldjsdlkfjsdlfjlk</div>';
	document.body.appendChild(bg);

  var info=document.createElement('div');
  info.setAttribute('id','info');
  info.style.width='300px';
  info.style.height='200px';
  info.style.left='50%';
  info.style.top='50%';
  info.style.position='absolute'; 
  info.style.lineHeight='1.7';
  document.body.appendChild(info);
  
  var center=document.createElement('div');
  center.setAttribute('id','center');
  center.style.position='absolute'; 
  center.style.background='#fff';
  center.style.border='1px solid #217AC1';
  center.style.width='300';
  center.style.height='100';
  center.style.margin='-50px -150px';
  document.getElementById('info').appendChild(center);
  
  var strong=document.createElement('strong');
  strong.style.display='block';
  strong.style.padding='2px 5px';
  strong.style.background='#EBF4FC';
  strong.style.color=bordercolor;
  strong.style.font='14px 宋体';
  strong.style.fontWeight='bold';
  strong.innerHTML='友情提示:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  document.getElementById('center').appendChild(strong);
  
  var p=document.createElement('p');
  p.setAttribute('align','center');
  p.style.font='12px 宋体';
  p.style.wordBreak='break-all';
  p.innerHTML=str+'!';//'哈哈哈哈哈 哈哈哈!';
  document.getElementById('center').appendChild(p);
  
  var p1=document.createElement('p');
  p1.setAttribute('id','btn');
  p1.setAttribute('align','center');
  p1.style.font='12px 宋体';
  document.getElementById('center').appendChild(p1);
  
	var button=document.createElement("input");
	button.setAttribute("type","button");
	button.setAttribute("value","确定");
	button.setAttribute("align","middle");
	button.style.width="60px";
	button.style.align="center";
	//button.style.marginLeft="265";
	//button.style.marginTop="0px";	
	button.style.background=bordercolor;
	button.style.border="1px solid "+ bordercolor;
	button.style.color="white";
	button.onclick=function(){
             document.body.removeChild(bg);
			 document.body.removeChild(info);
		}
	document.getElementById('btn').appendChild(button);


}</script>
 </BODY>
</HTML>



发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>