showModalDialog 模拟 prompt

来源:互联网 发布:青鸟云题库java答案 编辑:程序博客网 时间:2024/06/05 11:56

最近做东西的时候由于用到了PROMPT,但是这个实在太难看了,在CSDN里面转了一大圈但是都只说用showModalDialog模拟一个,没有实在的例子,于是自己做了一个,呵呵感觉不差 。
废话少说,先看演示,包括2个文件

文件一 222.htm

<HTML>
<HEAD>
<TITLE>showModalDialog实例-qq:55802492-作者:西瓜太狼</TITLE>
<script language="JavaScript">
function start(e1){
var s = window.showModalDialog('333.html',e1,'dialogWidth:300px;dialogHeight:170px;status:no;scroll:no');
document.myform.city.value
=document.myform.city.value+e1+''+s+'颗,<br> ';
}

</script>
</HEAD>
<BODY BGCOLOR="antiquewhite">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  
<tr>
    
<td width="49%"><form id="myform" name="myform" method="post" action="">
      
<textarea name="city" id="city" cols="60" rows="5"></textarea>
        
</form>
    
</td>
    
<td width="51%"><table width="100%" border="0" cellspacing="3" cellpadding="3">
      
<tr>
        
<td><href="#" onclick=start('框架放反')>框架放反</a></td>
      
</tr>
      
<tr>
        
<td><href="#" onclick=start('芯片装反')>芯片装反</a></td>
      
</tr>
      
<tr>
        
<td><href="#" onclick=start('多胶')>多胶</a></td>
      
</tr>
            
<tr>
        
<td><href="#" onclick=start('芯片错位')>芯片错位</a></td>
      
</tr>
            
<tr>
        
<td><href="#" onclick=start('胶水外漏')>胶水外漏</a></td>
      
</tr>
    
</table></td>
  
</tr>
</table>

</body>
</BODY>
</HTML>

文件二 333.htm

<HTML>
<HEAD>
<base target="_self">
<TITLE>输入提示框</TITLE>
<script language="javascript">
function end(){
var s=document.getElementById("num").value;
  
if(s=="")
    
{
      alert(
"请填写数量");
      
return false;
    }

window.returnValue
=s;
window.close();
}

</script>
<script language=javascript>
  
function   document.onkeydown()   
  
{   
        
if(event.keyCode==13)   
                end();   
  }
  
</script>
</HEAD>
<BODY BGCOLOR="oldlace" onUnload="end()">
    
<table width="100%" border="0" align="center" cellpadding="9" cellspacing="1" bgcolor="#FEFBF5">
  
<tr>
    
<td width="8%" height="48" align="right" bgcolor="#FDF5E6"><img src="jingao.gif" width="55" height="52"></td>
    
<td width="92%" bgcolor="#FDF5E6" style="
    FONT-WEIGHT: bold; FONT-SIZE: 14px;"
>请输入:<span style="FONT-WEIGHT: bold; FONT-SIZE: 14px; COLOR: red">
      
<script language="javascript">
var zhu=window.dialogArguments
window.document.write(zhu);
      
</script>
    
</span>的数量</td>
  
</tr>
  
<tr>
    
<td height="51" colspan="2" align="center">数量:      
    
<input name="num" type="text" id="num" size="10" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && (event.keyCode<48 || event.keyCode>57)) event.returnValue=false">    <input name="button" type="button" onClick="end()" value="确认/ENTER"></td>
    
</tr>
</table>
</BODY>
</HTML> 

原创粉丝点击