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 }


  • 相关阅读:
    MongoDb
    js暴露内部方法属性等
    JS闭包
    k8s设计模式
    scrum
    死锁
    Linux下安装php 扩展fileinfo
    linux中whereis、which、find、location的区别和用法
    Linux 命令学习记录
    windows 下 redis 的安装及使用
  • 原文地址:https://www.cnblogs.com/qieqing/p/1224133.html
Copyright © 2011-2022 走看看