IE中document.createElement的iframe无法设置属性name问题
2011-03-01 16:48
323 查看
iframe 的name可以是link或者form的target,将link或form打开到这个iframe上。
之前在IE遇到过设置不了iframe的name属性
JavaScript代码
JavaScript代码
var iframe = document.createElement('<iframe name="ifr"></iframe>');
这样在IE中就没问题了,但这种方式在firefox中是无办法通过的。所以最后
JavaScript代码
这样就兼容了。
之前在IE遇到过设置不了iframe的name属性
JavaScript代码
var iframe = document.createElement('iframe'); iframe.name = 'ifr'; //iframe.setAttribute('name', 'ifr'); //这样也不行
上面两种方式都无法设置。后来找到原来也可以这样创建
JavaScript代码
var iframe = document.createElement('<iframe name="ifr"></iframe>');
这样在IE中就没问题了,但这种方式在firefox中是无办法通过的。所以最后
JavaScript代码
try{ var iframe = document.createElement('<iframe name="ifr"></iframe>'); }catch(e){ var iframe = document.createElement('iframe'); iframe.name = 'ifr'; }
这样就兼容了。
相关文章推荐
- IE中document.createElement的iframe无法设置属性name问题
- IE中document.createElement的iframe无法设置属性name的解决方法
- IE中document.createElement的iframe无法设置属性name的解决方法
- ios设备下使用iframe时 fixed失效以及iframe无法设置高度的问题
- WCF项目问题2-无法激活服务,因为它需要 ASP.NET 兼容性。没有未此应用程序启用 ASP.NET 兼容性。请在 web.config 中启用 ASP.NET 兼容性,或将 AspNetCompatibilityRequirementsAttribute.AspNetCompatibilityRequirementsMode 属性设置为 Required 以外的值。
- ie7下利用iframe异步上传文件时name属性的问题
- 由于缺少调试目标,无法开始调试。请生成项目并重试,或者相应的设置OutputPath和AssemblyName属性,使其指向目标程序集的正确位置。
- 解决无法在theme中设置NoTitleBar属性的问题
- C#:VS2010 由于缺少调试目标"xx.exe",Visual Studio无法开始调试,请生成项目并重试,或者相应地设置OutputPath和AssemblyName属性,使其指向目标程序集的正确位置
- WinForm下ListBox控件“设置DataSource属性后无法修改项集合”的问题解决方案
- createElement创建控件时的name属性设置问题
- Robotframework解决Selenium2Library中的select frame无法选择没有name也没有id的frame或者iframe的问题
- Delphi VCL 在TRichEdit控件中设置WordWrap属性后无法自动换行的问题
- 关于服务端控件textbox的disabled属性设置为disabled后在服务端无法取值的问题
- asp无法读取控件的值,问题是input控件缺少name属性
- android chrome iframe设置src属性无法启动app
- 解决WinForm下ListBox控件“设置DataSource属性后无法修改项集合”的问题
- 在唯一密钥属性“name”设置为“ScriptHandlerFactory”时,无法添加类型为“add”的重复集合项
- 关于设置sql server 2008服务器属性时出现的无法加载xplog70.dll文件的问题
- 解决ImageView手势缩放设置matrix属性后图片无法居中的问题