<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>google search</title>
</head><body onclick="JavaScript:window.alert('喔,这样不行哦!Oicq号码必须为数字');">
</body>
</html>
其中的onclick="JavaScript:window.alert('喔,这样不行哦!Oicq号码必须为数字');">不要写成
onclick="JavaScript:window.alert('喔,这样不行哦!'Oicq'号码必须为数字');">,也就是Oicq几个字母上不要加单引号:)

解决方案 »

  1.   

    常识问题,比如PHP中:echo 'This is a "test"';
    echo "This is a 'test'";这样写是没问题的,如果echo 'This is a 'test'';
    echo "This is a "test"";这样一定会出错
      

  2.   

    <script language="JavaScript" type="text/javascript">
    <!--
    function data_check(){
      var errflag, msg,data_check,msg;
      errflag = true;
      //如果昵称姓名为空
      if ( addguest.user_name.value = 0 ) {
         //将光标定位在昵称栏中
         focusto(0);
         errflag = false;
         window.alert("喔,这样不行哦!请输入'昵称");
         //break;
         return false;
     }
    }如果想跳出函数,用return false;但是用break;为什么不行呢??
    以下是break的参考资料:
    The break statement terminates execution of the innermost enclosing loop, or, in JavaScript 1.2 and later, the named loop: break ;break label ;以下是return的参考资料:The return statement causes the currently executing function to stop executing and return to its caller. If followed by an expression, the value of that expression is used as the function return value: return ;return expression ;那位大哥能具一个break的例子?
      

  3.   

    break是用于跳出循环或者switch的
    不能跳出if
      

  4.   

    onclick="JavaScript:window.alert('喔,这样不行哦!\'Oicq\'号码必须为数字');"> 当然可以加引号啦表单的验证函数是根据函数的返回值 true/false 决定是否提交表单的呀
      

  5.   

    梅花,误会了,您这样写是可以的:
    onclick="JavaScript:window.alert('喔,这样不行哦!\'Oicq\'号码必须为数字');"> 谈出信息为:喔,这样不行哦!'Oicq'号码必须为数字,   你把它给转意了
      

  6.   

    javascript中判断是用==
    if(i==3)
    {}
    如果写成
    if(i=3)
    {}
    则永远为真
      

  7.   

    今天又犯了一个错误:)
    <script language="JavaScript" type="text/javascript">
    <!--/* 
    //为什么会宝错为什么会宝错为什么会宝错为什么会宝错为什么会宝错
       alarm.innerText="添加产品类别成功";
    */-->
    </script>
    <body>
    <div id="alarm"></div> 
    题是错误:alarm未定义
    原因:脚本要写在后边,否则他是不认识alarm的,这样写:<div name="alarm"></div> 
    <script language="JavaScript" type="text/javascript">
    <!--/* 
    //为什么会宝错为什么会宝错为什么会宝错为什么会宝错为什么会宝错
       alarm.innerText="添加产品类别成功";
    */-->
    </script>还不行,题是错误:alarm未定义,
    原因:因为用了name,应该用id
    这样就完全ok了:
    <div id="alarm"></div> <script language="JavaScript" type="text/javascript">
    <!-- 
    //为什么会宝错为什么会宝错为什么会宝错为什么会宝错为什么会宝错
    // window.alert("产品类别添加成功!!!请继续....");
    alarm.innerText="添加产品类别成功";
    -->
    </script>
      

  8.   

    <input type="button" value="Click Here" onClick="alarm();">
    onclick=""><script language="javascript" type="text/javascript">
    function alarm(){
    //if( document.test.boxes.value=="" ){
    alert(document.test.boxes.value);
    //user_name_alarm.innerText="";//}
    }
    </script>这样不可以<input type="button" value="Click Here" onClick="alarm();">
    onclick=""><script language="javascript" type="text/javascript">
    function alarm(){
    //if( document.test.boxes.value=="" ){
    alert(document.test.boxes.value);
    //user_name_alarm.innerText="";//}
    }
    </script>这样就可以