-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