无法选择留在Iframe广告超出可视区域中的文本 [英] Unable to select the text left in the Iframe beyond the visible area

查看:77
本文介绍了无法选择留在Iframe广告超出可视区域中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MVC3和我的iframe在我的网页,并为此设计的iFrame模式开启在运行时进行编辑。而在IE9运行此,我无法选择文本超出iframe的可视区域。例如:如果第7行是在我的iFrame可见,然后当我滚动选择在10日线的内容,那么选择不会发生。

I am using MVC3 and I have an Iframe in my page, and design mode for this Iframe is turned on for editing at run time. while running this in IE9, I am unable to select the text beyond the visible area of the Iframe. For example: if the first 7 lines are visible in my Iframe, then when I scroll to select the content in the 10th line, then the selection does not occur.

<iframe id="RFrame" runat="server" style="width: 900px;"></iframe>

<script type="text/javascript">

    Sys.Application.add_load(PageLoad);

    function PageLoad() {
        var frame = $get('<%=this.RFrame.ClientID%>');
        $get('<%=this.RFrame.ClientID%>').contentDocument.designMode = "on";
        frame.focus();
    }
</script>

请注意:这工作得很好,除了IE9其他所有浏览器。只有当文档模式为库巴模式IE9设为IE9默认情况下会发生问题。

Note: this works fine in all other browsers except IE9. issue occurs only when the document mode is set as IE9 by default for bowser mode IE9.

任何人都可以让我知道这种行为或如何之所以要解决此问题?

Can anyone let me know the reason for this behavior or how to resolve this?

推荐答案

您正面临被设置的designMode引起的问题=

The problem you are facing is caused by setting designMode = "on"

要解决此问题不开设置的designMode =,而不是设置CONTENTEDITABLE =真。

To fix this issue do not set designMode = "on", instead set contentEditable = true.

例如:

var editor = document.getElementById("RFrame");
editorDoc = editor.contentWindow.document;          
var editorBody = editorDoc.body;
editorBody.contentEditable = true;

这也将在兼容模式下被禁止删除由IE9显示的iframe水平滚动条。

This will also remove the horizontal scrollbar from the IFRAME displayed by IE9 when compatibility mode is disabled.

这篇关于无法选择留在Iframe广告超出可视区域中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆