-1
A
回答
0
林不知道究竟你被选中的文字是什么意思,但是这是你如何访问一个iframe的内容与jQuery
$('#iFrameID').contents().find('#whatImLookingFor').text(getSelectedText());
function getSelectedText(){
if(window.getSelection){
return window.getSelection().toString();
}
else if(document.getSelection){
return document.getSelection();
}
else if(document.selection){
return document.selection.createRange().text;
}
}
+0
选择文本的意义(使用鼠标选定的文本) – Santhosh 2009-11-13 04:40:58
2
忽略了什么我已经写了,那是垃圾。
这是实打实的:
var iframe= document.getElementById('yourFrameId');
var idoc= iframe.contentDocument || iframe.contentWindow.document; // For IE.
alert(idoc.getSelection());
以上是公然从bobince's答案被盗this SO Question
0
不知道你在iframe的意思编辑真实的东西。可能是文本框或者textarea。但是,如果你真的有一个iframe,在一些文本被选中,那么这里是一个代码段,应该在一些浏览器的工作:
var iframe = document.getElementById("frame1");
var txt = "";
if (iframe.contentWindow.getSelection) {
txt = iframe.contentWindow.getSelection();
} else if (iframe.contentWindow.document.getSelection) {
txt = iframe.contentWindow.document.getSelection();
} else if (iframe.contentWindow.document.selection) {
txt = iframe.contentWindow.document.selection.createRange().text;
}
相关问题
- 1. 在IE中获取iframe中的选定文本
- 2. 如何使用rangy从iframe中抓取选定的文本?
- 3. iframe和文本定位
- 4. 更改iframe跨浏览器上的选定文本
- 5. 从asp.net c#中使用iframe中的网页检索选定的文本?
- 6. 的JavaScript/jQuery的进去的iframe当前选中的文本
- 7. 如何从javascript中的iframe中选择文本?
- 8. 使用JavaScript从iframe中获取指向不同域的选定文本
- 9. Jquery Iframe文本框
- 10. iframe的替代文本
- 11. 文本重叠的iframe
- 12. 将选定的项目ListBox到选定的文本框中
- 13. 选定文本的HTML
- 14. 检测选定的文本
- 15. 捕捉选定的文本
- 16. 期望选定的文本
- 17. iframe中的文本使用php
- 18. 更改Iframe中的文本颜色
- 19. iframe中doc文件的本地路径
- 20. 突出显示iframe中的文本
- 21. 如何删除文本中的iframe src?
- 22. iframe中的jquery搜索文本
- 23. iframe中的WKWebView本地文件
- 24. 替换contenteditable div中的选定文本
- 25. C#RichTextBox中选择指定的文本
- 26. 用于Javascript中选定文本的nodeName
- 27. 更改jHtmlArea中的选定文本
- 28. 在Emacs中包含选定的文本
- 29. 替换Firefox中的选定文本
- 30. 如何从javascript中使用iframe选择文本?
这是http://stackoverflow.com/questions的精确副本/ 1471759/how-to-get-selected-text-from-iframe-with-javascript – 2009-11-13 04:45:15
@Dan McG - 然后投票! – 2009-11-13 04:51:47
-1。我知道我忘了一些东西... – 2009-11-13 05:16:21