藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年8月25日 8:28

請教:如何讓頁面停止繼續活動

請問,javascript有沒有能讓網頁停止下面的活動的語句或是程序?? :( :confused:

eg:

[code]請問,javascript有沒有能讓網頁
停止
<SCRIPT LANGUAGE="JavaScript">
<!--
        document.execCommand("stop")
//-->
</SCRIPT>
下面的活動的語句或是程序??
[/code]
[color=red]請拷貝到本地測試[/color]


我寫了一個 <form name="form1" method="post"action="mailto:it@montecarlofurniture.com">
然後在submit上寫了個onblur=load()函數用來檢驗郵件內容是否正確.現在讓我頭疼的是,即使郵件內容不正確,仍然會出現一個發郵件的提示框,問我是否要以表單形式發送郵件.怎樣才能不讓後面那個提示框出現呢?
謝謝*-*

<form onsubmit="return load()">
-----
load(){
if(不正確)
return false;
}
---------
這樣可以在load不通過的情況下不提交表單

先謝謝tzboy:)
不過,我試了試,還是會發:(

<html>
<head>
<title>Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Page-Enter" content="revealTrans(Duration=2.0,Transition=12)">
<style type="text/css">
<!--
a:visited {
        cursor: hand;
        text-decoration: none;
        color: #FFFFFF;
}

</style>

<style type="text/css">
<!--
.style2 {
        color: #FFFFFF;
        font-size: 14px;
        font-weight: bold;
        font-family: Arial, Helvetica, sans-serif;
        border: #FFFFFF;
}
.style9 {
        font-family: "Century Gothic";
        font-weight: bolder;
        font-size: 12px;
        color: #FFFFFF;
}
.style18 {font-weight: bold; color: #FFFFFF;}
.style22 {color: #FFFFFF; font-size: 16px; font-family: Papyrus; }
.style23 {font-family: Papyrus; font-weight: bold; font-size: 16px; color: #FFFFFF; }
.style26 {
        color: #999999;
        font-size: 12px;
}
.style32 {
        font-size: 12px;
        color: #FFFFFF;
        font-family: "Century Gothic";
        font-weight: bold;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function load()
{
    var flag = true;
        var mail =form1.email.value;
        //驗證姓名是否填寫
        if  (form1.name.value=="")
          {
              alert("Please input your name.");
                  form1.name.select();
                  form1.street.focus();
                  flag= false;
                  return false;
               
          }
        //驗證street是否為空
        if (form1.street.value=="" && flag==true)
         {
              alert("Please input your street.");
                  form1.street.select();
                  form1.street.focus();
                  flag= false;
         }
        //驗證phone是否為空
        if (form1.phone.value=="" && flag==true)
         {
              alert("Please input your phone.");
                  form1.phone.select();
                  form1.phone.focus();
                  flag= false;
         }
        //驗證郵件地址是否正確
        if (((mail.indexOf("@")<0 )||( mail.indexOf(".")<0) )&& flag==true)
         {
              alert("please input your correct e_mail address.");
                  form1.email.select();
                  form1.email.focus();
                  flag=false;
         }
                
        if (flag==true)
     {
            window.location.href="contacted.htm";
         }
}
//-->
</script>
<link href="submit.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style33 {
        font-family: "Century Gothic";
        font-weight: bold;
        font-size: 24px;
        color: #FFFFFF;
}
.style34 {
        font-family: "Century Gothic";
        font-weight: bold;
        font-size: 14px;
        color: #FFFFFF;
}
a:link {
        color: #FFFFFF;
        text-decoration: none;
}
a:hover {
        text-decoration: none;
}
a:active {
        text-decoration: none;
        color: #FFFFFF;
}
.style38 {
        font-size: 14px;
        font-family: "Century Gothic";
        font-weight: bolder;
        color: #FFFFFF;
}
.style42 {font-family: "Century Gothic"; font-size: 12px; font-weight: bold; color: #666666; }
.style43 {font-size: 12px; color: #666666; font-family: "Century Gothic";}
.style45 {color: #666666}
.style47 {font-size: 12px; font-family: "Century Gothic"; }
-->
</style>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p style="margin-top: 1px; margin-bottom: 1px"> </p>
<table width="94%" border="0" cellpadding="0" cellspacing="0"   align="center">
  <tr bgcolor="#B06240"  >
    <td width="46" height="63">
    <pre class="style2">&nbsp;  </pre></td>
    <td width="265" class="style32">
        <p style="margin-top: -1px; margin-bottom: -1px">
        <span class="style9">WWW.MONTECARLOFURNITURE.COM</span></td>
    <td width="51"> </td>
    <td width="53" class="style9"><div align="center" class="style22">
      <div align="left" class="style18">
                <p style="margin-top: -1px; margin-bottom: -1px">
                <font face="Century Gothic" size="2"><a href="index.htm" class="style9">HOME</a></font></div>
    </div></td>
   
    <td width="51" class="style9"><div align="center" class="style22">
      <div align="left" class="style18">
                <p style="margin-top: -1px; margin-bottom: -1px">
                <font face="Century Gothic" size="2"><a href="sofa.htm" class="style9">SOFA</a></font></div>
    </div></td>
    <td width="105" class="style9"> <div align="left" class="style23">
                <p style="margin-top: -1px; margin-bottom: -1px">
                <font face="Century Gothic" size="2"><a href="bed.htm" class="style9">BEDCHAMBER</a></font></div></td>
    <td width="108" class="style9">
        <p style="margin-top: -1px; margin-bottom: -1px">
        <font face="Century Gothic" size="2"><a href="dining.htm" class="style9">DINING-ROOM </a></font></td>
    <td width="98" class="style23">
        <p style="margin-top: -1px; margin-bottom: -1px">
        <font face="Century Gothic" size="2"><a href="furni.htm" class="style9">LIVING-ROOM</a></font></td>
    <td width="63" class="style9">
        <p style="margin-top: -1px; margin-bottom: -1px">
        <span class="style9">CONTACT</span></td>
    <td width="58"> </td>
  </tr>
  <tr >
    <td height="351" colspan="12"   bgcolor="#BF7837"><table width="894" height="347" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="41" height="16"> </td>
        <td width="383"> </td>
        <td width="429"> </td>
        <td width="41"> </td>
      </tr>
      <tr>
        <td height="331">  </td>
        <td>
            <form name="form1" method="post" action="mailto:it@montecarlofurniture.com">
              <table width="347" height="286" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="138" height="22">
                                <p style="margin-bottom: -1px"><input type="text"   size="23" style="border: 1 solid #FFFFFF; font-family:Century Gothic; color:#B56142; font-size:10pt; font-weight:bold" name="name" ></td>
              <td width="70" height="22"> </td>
              <td width="139" height="22">
                                <p style="margin-top: -1px"><input type="text"  size="23" style="border: 1 solid #FFFFFF; font-family:Century Gothic; font-size:10pt; color:#B56142; font-weight:bold" name="company" ></td>
            </tr>
            <tr>
              <td height="24" class="style38">
                                <p style="margin-top: -4px">NAME</td>
              <td height="24"> </td>
              <td height="24" class="style38">
                                <p style="margin-top: -4px">COMPANY</td>
            </tr>
            <tr>
              <td height="22"><input type="text"  size="23" style="border: 1 solid #FFFFFF; color:#B56142; font-size:10pt; font-family:Century Gothic; font-weight:bold" name="street" ></td>
              <td height="22"> </td>
              <td height="22"><input type="text"  size="23" style="border: 1 solid #FFFFFF; font-size:10pt; font-family:Century Gothic; color:#B56142; font-weight:bold" name="zip/city" ></td>
            </tr>
            <tr>
              <td height="24" class="style38">
                                <p style="margin-top: -4px">STREET</td>
              <td height="24"> </td>
              <td height="24" class="style38">
                                <p style="margin-top: -4px">ZIP/CITY</td>
            </tr>
            <tr>
              <td height="22"><input type="text"  size="23" style="border: 1 solid #FFFFFF; color:#B56142; font-size:10pt; font-family:Century Gothic; font-weight:bold" name="phone" ></td>
              <td height="22"> </td>
              <td height="22">
                    <input type="text" size="23" style="border: 1 solid #FFFFFF; font-size:10pt; font-family:Century Gothic; color:#B56142; font-weight:bold" name="fax" >
                  </td>
            </tr>
            <tr>
              <td class="style38" height="24">
                                <p style="margin-top: -4px">PHONE</td>
              <td height="24"> </td>
              <td class="style38" height="24">
                                <p style="margin-top: -4px">FAX</td>
            </tr>
            <tr>
              <td height="22"><input type="text"  size="23" style="border: 1 solid #FFFFFF; color:#B56142; font-size:10pt; font-family:Century Gothic; font-weight:bold" name="email" ></td>
              <td height="22"> </td>
              <td height="22"><input type="text" size="23" style="border: 1 solid #FFFFFF; font-size:10pt; font-family:Century Gothic; color:#B56142; font-weight:bold" name="web" ></td>
            </tr>
            <tr>
              <td height="24" class="style38">
                                <p style="margin-top: -4px">E-MAIL</td>
              <td height="24"> </td>
              <td height="24" class="style38">
                                <p style="margin-top: -4px">WEB</td>
            </tr>
            <tr>
              <td height="79" colspan="3">
                                <textarea name="textarea" rows="5" cols="45" style="float: left; height: 80; width: 349; border-style: solid; border-width: 1px; padding-left: 0; padding-bottom: 3px ;overflow:hidden; line-height:100%; font-family:Century Gothic; color:#B56142; font-size:10pt" class="style23" ></textarea></td>
              </tr>
            <tr>
              <td class="style38">
                                <p style="margin-top: -4px">COMMENTS</td>
              <td> </td>
              <td><b>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="Submit" type="submit" class="submit"  onBlur="return load()"    value="SEND FORM" style="padding:-1px; font-family: Century Gothic; color: #FFFFFF; font-weight: bold; font-size: 10pt;border: 0px solid #BD7931; background-color: #BD7931;cursor: hand; width:73; height:20" ></b></td>
            </tr>
          </table>
        </form></td>
        <td> 
          <table width="428" height="264" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="82"> </td>
              <td width="286"> </td>
              <td width="60"> </td>
            </tr>
            <tr>
              <td height="42"> </td>
              <td><span class="style33">CONTACT</span></td>
              <td> </td>
            </tr>
            <tr>
              <td height="24"> </td>
              <td><span class="style34">You want to get in touch with us? </span></td>
              <td> </td>
            </tr>
            <tr>
              <td height="23"> </td>
              <td><span class="style34">Here is a survey of all relevant data. </span></td>
              <td> </td>
            </tr>
            <tr>
              <td height="24"> </td>
              <td> </td>
              <td> </td>
            </tr>
            <tr>
              <td> </td>
              <td> </td>
              <td> </td>
            </tr>
            <tr>
              <td height="55"> </td>
              <td> </td>
              <td> </td>
            </tr>
          </table></td>
        <td> </td>
      </tr>
    </table></td>
  </tr>
  <tr  >
    <td height="16" colspan="12"  > </td>
  </tr>
  <tr >
    <td colspan="12"   bgcolor="#FFFFFF"  >
      <div align="center">
        <table width="100%"  border="1" cellpadding="0" cellspacing="0" style="border: 1px solid #999999; " >
          <tr>
            <td width="100%" height="123" bordercolor="#999999" align="left"  >
              <table width="883" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="445" height="24" align="left">
                    <div align="left"><span class="style42">Address :</span></div>
                  </td>
                  <td width="24" height="24"> </td>
                  <td width="414" height="24" align="left"><span class="style42">E-mail
                    :</span></td>
                </tr>
                <tr>
                  <td height="24" align="left" width="445">
                    <div align="left"><span class="style43">Block#100.Zhujiang
                      Road.New Zone.WUXI.JiangSu Prov.China 214028</span> </div>
                  </td>
                  <td height="24"> </td>
                  <td height="24" align="left"> <span class="style43"><strong>Research and Development Department :</strong> <a href="mailto:rd@montecarlofurniture.com"><font color="#000000">[email]rd@montecarlofurniture.com[/email]</font></a></span></td>
                </tr>
                <tr>
                  <td height="24" align="left" width="445">
                    <div align="left"><span class="style45"><span class="style42">Tel
                      : </span><span class="style47"> 86 510 5342266</span></span></div>
                  </td>
                  <td height="24"> </td>
                  <td height="24" align="left"><span class="style43"><strong>Sales Department :</strong> <a href="mailto:pd@montecarlofurniture.com"><font color="#000000">[email]pd@montecarlofurniture.com[/email]</font></a></span></td>
                </tr>
                <tr>
                  <td height="24" align="left" width="445">
                    <div align="left"><span class="style45"><span class="style47">
                      </span> <span class="style42">Fax : </span><span class="style47">86
                      510 5344028</span> </span></div>
                  </td>
                  <td height="24"> </td>
                  <td height="24" align="left"><span class="style43"> <strong>Secretarial Pool :</strong><a href="mailto:sp@montecarlofurniture.com"><font color="#000000">
                    [email]sp@montecarlofurniture.com[/email]</font></a></span></td>
                </tr>
                <tr>
                  <td height="18" width="445">&nbsp;</td>
                  <td height="18">&nbsp;</td>
                  <td height="18"><span class="style43"><strong>IT Department
                    :</strong><a href="mailto:it@montecarlofurniture.com"><font color="#000000">
                    [email]it@montecarlofurniture.com[/email]</font></a></span></td>
                </tr>
              </table>
          </td>
        </tr>
      </table>

             </div>

    </td>
  </tr>
</table>

<table width="730" height="23" border="0" align="right" cellpadding="0" cellspacing="0">
  <tr>
    <td width="568" height="16">&nbsp;</td>
    <td width="162" class="style26"> PRODUCED BY MONTECARLO </td>
  </tr>
</table>

</body>
</html>



是所有的源碼:)

<input name="Submit" type="submit" class="submit" onBlur="return load()" value="SEND FORM" style="padding:-1px; font-family: Century Gothic; color: #FFFFFF; font-weight: bold; font-size: 10pt;border: 0px solid #BD7931; background-color: #BD7931;cursor: hand; width:73; height:20" >

把onBlur改為onClick試試

謝謝leojay1:)現在問題解決拉*—*




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com