-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. 使用JS獲取選定的文本 - 即使在iFrame中
- 3. 獲取任何iframe中的選定文本
- 4. 如何使用rangy從iframe中抓取選定的文本?
- 5. iframe和文本定位
- 6. 如何從iframe中獲取下拉選定文本?
- 7. 文本框中的選定文本
- 8. 更改iframe跨瀏覽器上的選定文本
- 9. 從asp.net c#中使用iframe中的網頁檢索選定的文本?
- 10. 將iframe滾動到所選文本
- 11. 的JavaScript/jQuery的進去的iframe當前選中的文本
- 12. 如何從javascript中的iframe中選擇文本?
- 13. 使用JavaScript從iframe中獲取指向不同域的選定文本
- 14. 如何在iframe中加載文本框中指定的URL?
- 15. Jquery Iframe文本框
- 16. Iframe文本does not
- 17. iframe正確的文本
- 18. iframe的替代文本
- 19. 文本重疊的iframe
- 20. 將選定的項目ListBox到選定的文本框中
- 21. 選定文本的HTML
- 22. document.elementFromPoint爲選定的文本
- 23. 設置選定的文本
- 24. 期望選定的文本
- 25. 檢測選定的文本
- 26. 捕捉選定的文本
- 27. 分享選定的文本
- 28. 用圖像替換Iframe中的文本
- 29. iframe中doc文件的本地路徑
- 30. iframe中的jquery搜索文本
這是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