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 }


  • 相关阅读:
    python工具类 md5
    python 线程池, 进程池
    scrapydweb 安装部署
    python 协程
    jquery
    scrapyd 设置访问密码
    pat 乙级1033 旧键盘打字(20)
    1459 迷宫游戏(51NOD)
    python之禅
    Jzzhu and Cities ----CodeForces
  • 原文地址:https://www.cnblogs.com/qieqing/p/1224133.html
Copyright © 2011-2022 走看看