zoukankan      html  css  js  c++  java
  • [jQuery] Form中会导致IE6崩溃的提交 Crash of the form in IE6

    页面代码如下: -- As the code below

    代码
    <form onsubmit="sbSearch();return false;" method="get" action="test.php" id="sbSearchForm">
      <label style="display: none;" for="sbText">sbText</label>
      <input type="text" onclick="if(this.value=='Search text')this.value=''" onblur="if(this.value=='')this.value='Search text';" value="Search text" name="SearchText" id="sbText" />
      <input type="submit" value="submit" />
    </form>
    <script type="text/javascript">
    //<![CDATA[
    function sbSearch()
    {
    if(jQuery("#sbText").val() == "Search text" || jQuery("#sbText").val() == "")
    {
    alert(
    "Please fill the field");
    jQuery(
    "#sbText").focus();
    return false;
        }
        else
        {
        jQuery(
    "#sbSearchForm").submit();
        }
    }
    //]]>
    </script>

    在 IE6下,当输入文字,然后回车,会出现浏览器关掉的问题。

    Under IE6, aftering inserted the words, and then press the enter, then the browser will close selftly.


    现在找到的解决办法, 如下面javascript里面红色加粗。

    Now the resolved as below, pay attention to the code in javascript marked red bold.

    代码
    <script type="text/javascript">
    //<![CDATA[ 
    function sbSearch()
    {
    if(jQuery("#sbText").val() == "Search text" || jQuery("#sbText").val() == "")
    {
    alert(
    "Please fill the field!");
    jQuery(
    "#sbText").focus();
    return false;
    }
    else
    {
    jQuery(
    "#sbSearchForm")[0].submit();
    }
    }
    //]]>
    </script>

  • 相关阅读:
    HDU 3586 二分答案+树形DP判定
    POJ 3140 树形DP
    POJ 1741 树的点分治
    POJ 1655 求树的重心
    CF 219D 树形DP
    HDU 2196树形DP(2个方向)
    HDU 1520 树形DP入门
    POJ 1159 Palindrome(最长公共子序列)
    树状数组 区间更新 区间查询
    HDU 1556 BIT区间修改+单点查询(fread读入优化)
  • 原文地址:https://www.cnblogs.com/davidhhuan/p/1763566.html
Copyright © 2011-2022 走看看