无法选择 Iframe 中超出可见区域的文本
我正在使用 MVC3,并且我的页面中有一个 Iframe,并且该 Iframe 的设计模式已打开以便在运行时进行编辑。在 IE9 中运行此程序时,我无法选择 Iframe 可见区域之外的文本。例如:如果前 7 行在我的 Iframe 中可见,那么当我滚动选择第 10 行中的内容时,不会发生选择。
<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 之外,这在所有其他浏览器中都可以正常工作。仅当 Bowser 模式 IE9 默认将文档模式设置为 IE9 时,才会出现此问题。
谁能让我知道这种行为的原因或如何解决这个问题?
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>
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您面临的问题是由设置 designMode = "on" 引起的
要解决此问题,请勿设置 designMode = "on",而是设置 contentEditable = true。
示例:
禁用兼容模式时,这还将从 IE9 显示的 IFRAME 中删除水平滚动条。
The problem you are facing is caused by setting designMode = "on"
To fix this issue do not set designMode = "on", instead set contentEditable = true.
Example:
This will also remove the horizontal scrollbar from the IFRAME displayed by IE9 when compatibility mode is disabled.