<html>
<body>
<script type="text/javascript">
function smth() {
if (document.getSelection) {
var str = document.getSelection();
if (window.RegExp) {
var regstr = unescape("%20%20%20%20%20");
var regexp = new RegExp(regstr, "g");
str = str.replace(regexp, "");
}
} else if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
var str = range.text;
}
alert(str);
}
</script>
<iframe id="my" width="300" height="225">
.....some html ....
</iframe>
<a href="#" onclick="smth();">AA</a>
</body>
</html>
smth
फ़ंक्शन के साथ मैं कुछ div से चयनित टेक्स्ट प्राप्त कर सकता हूं, लेकिन यह iframe के साथ काम नहीं करता है। किसी भी विचार को iframe से चयनित पाठ कैसे प्राप्त करें?जावास्क्रिप्ट के साथ iframe से चयनित पाठ कैसे प्राप्त करें?
ठीक है, खेद गलत उदाहरण के लिए, iframe में मैं पाठ है, मैं wysiwig संपादक के लिए iframe उपयोग करते हैं, तो यह अलग डोमेन पर नहीं है। –
जानकारी के लिए धन्यवाद। –