<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>
con la función smth
puedo obtener el texto seleccionado de algún div, pero no funciona con iframe. alguna idea de cómo obtener el texto seleccionado de iframe?cómo obtener el texto seleccionado de iframe con javascript?
ejemplo ok, lo siento mal, en el marco flotante tengo texto, yo uso iframe para editor WYSIWYG, por lo que no es de dominio diferente. –
Gracias por la información. –