zoukankan      html  css  js  c++  java
  • Opera9.5 关于IFRAME编辑模式的小问题

    editFrameWindow  →  IFRAME对象.contentWindow

    1 editFrameWindow.document.designMode = 'On';
    2 editFrameWindow.document.open();
    3 editFrameWindow.document.writeln('<html><head>');
    4 editFrameWindow.document.writeln('</head><body></body></html>');       
    5 editFrameWindow.document.close();


    在IE6+,Opera9+(不包括9.5),FF2+ ,Safari 下都可以正常编辑,到了Opera9.5 这样写的话该IFRAME将不可以编辑,也不报错。问题出在这里:

    1 editFrameWindow.document.open();
    2 editFrameWindow.document.writeln('<html><head>');
    3 editFrameWindow.document.writeln('</head><body></body></html>');       
    4 editFrameWindow.document.close();

    这段代码是为了让FF2+正常编辑而写的,其他浏览器都则可以忽视这一段代码,不过现在Opera9.5已经不能忽视了。

    解决办法就是针对FF2+(Gecko内核)的浏览器 判断执行。



    1 editFrameWindow.document.designMode = 'On';
    2 if(navigator.userAgent.indexOf('Gecko'> -1 && navigator.userAgent.indexOf('KHTML'== -1) {
    3     editFrameWindow.document.open();
    4     editFrameWindow.document.writeln('<html><head>');
    5     editFrameWindow.document.writeln('</head><body></body></html>');       
    6     editFrameWindow.document.close();
    7 }


  • 相关阅读:
    HTTP协议图解
    .NET 发布网站步骤
    使用php在服务器端生成图文验证码
    SQLServer复习文档1(with C#)
    理解 JavaScript 原型 / 原型链
    浅谈瀑布流
    懒加载
    jQuery ajax
    jQuery 动画效果 与 动画队列
    jQuery 事件
  • 原文地址:https://www.cnblogs.com/qieqing/p/1224133.html
Copyright © 2011-2022 走看看