zoukankan      html  css  js  c++  java
  • IE、Firefox兼容form target当前页iframe,javascript动态创建表单对象form设置name属性

    一、

    不兼容的测试代码:

      <body>
        
    <form  action="http://www.baidu.com" method="post" id="form_forwrad_forword" >
            
    <input type="submit" value="submit"/>
        
    </form>
        
        
        
    <iframe id="loginIframe"   width="300" height="300"></iframe>
      
    </body>
    </html>
    <script language="javascript">
        
    var _form=document.getElementById("form_forwrad_forword");
        _form.setAttribute(
    "target","loginIframe");
    </script>

     IE:点击“submit”提交之后,form表单并未按照预想提交到“loginIframe”这个iframe中。

    FF:点击“submit”提交之后,form表单按照预想提交到“loginIframe”这个iframe中。

    解决此兼容问题: 在iframe中增加name属性即name=“loginIframe

    <iframe id="loginIframe"  name="loginIframe" width="300" height="300"></iframe>

    二、解决javascript动态创建表单对象form设置name属性(IE、FF兼容)


    function AFTER_FORMCREATE_FN(){
        
    var _iframe;
        
    try { // for I.E.
            _iframe= document.createElement('<iframe name="loginIframe">');
        } 
    catch (ex) { //for other browsers, an exception will be thrown
            _iframe = document.createElement('iframe'); 
        }
        
        _iframe.setAttribute(
    "id","loginIframe");
        _iframe.setAttribute(
    "name","loginIframe");
        _iframe.setAttribute(
    "height","300");
        _iframe.setAttribute(
    "style","display:none;");   
        document.body.appendChild(_iframe); 
           
        
    var _form=document.getElementById("form_forwrad_forword");
        _form.setAttribute(
    "target","loginIframe");
    }

  • 相关阅读:
    【转载】mysqldump的single-transaction和master-data
    MySQL 从库日志比主库多
    Error_code: 2003
    通过替换frm文件方式修改表结构
    ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
    批量kill mysql processlist进程
    libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.9-1.el6.x86_64
    MySQL 5.7.9的多源复制
    Java-Clone 对象拷贝
    Windows 运行库
  • 原文地址:https://www.cnblogs.com/jifeng/p/2169850.html
Copyright © 2011-2022 走看看