【问题标题】:How to get selection of iFrame?如何选择 iFrame?
【发布时间】:2012-01-06 21:01:28
【问题描述】:

如果至少使用 chrome 查看,则以下代码会在当前页面上显示带有所选文本的消息:

alert(window.getSelection());

但是,即使选择的是 iFrame 内的文本,我怎样才能让它工作呢? (iFrame内容属于同一个域)

【问题讨论】:

    标签: javascript google-chrome iframe getselection


    【解决方案1】:

    这应该可行:

    document.getElementById('iframe_id').contentWindow.getSelection();
    

    【讨论】:

    • 谢谢!实际上,您似乎想在 Chrome 中使用 ...contentDocument.getSelection() 。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多