R
riog
Hi,
Im trying to get the selected text from a textbox. window.getSelection
does not work in Firefox. Can you provide a solution or work-around
for this?
Here's my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<TITLE>test.html</TITLE>
<style type="text/css">
#result { font-style:italic;border:1px solid; height:100px;
overflow:auto;}
</style>
<SCRIPT type="text/javascript">
function okButtonClickListener() {
document.getElementById("result").innerHTML =
window.getSelection();
}
function inputTextKeypressListener() {
document.getElementById("result").innerHTML = window.getSelection();
}
</SCRIPT>
</HEAD>
<BODY>
<input type="text" onkeypress="inputTextKeypressListener();"/>
<p>
Select a text and mouse over here to view selection text (or click the
Ok button).
</p>
<b>Input Text Selection:</b><div id="result"
onmouseover="inputTextKeypressListener()"></div>
<input type="button" value="Ok" onclick='okButtonClickListener();'/>
</BODY>
</HTML>
Thanks,
riog
Im trying to get the selected text from a textbox. window.getSelection
does not work in Firefox. Can you provide a solution or work-around
for this?
Here's my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<TITLE>test.html</TITLE>
<style type="text/css">
#result { font-style:italic;border:1px solid; height:100px;
overflow:auto;}
</style>
<SCRIPT type="text/javascript">
function okButtonClickListener() {
document.getElementById("result").innerHTML =
window.getSelection();
}
function inputTextKeypressListener() {
document.getElementById("result").innerHTML = window.getSelection();
}
</SCRIPT>
</HEAD>
<BODY>
<input type="text" onkeypress="inputTextKeypressListener();"/>
<p>
Select a text and mouse over here to view selection text (or click the
Ok button).
</p>
<b>Input Text Selection:</b><div id="result"
onmouseover="inputTextKeypressListener()"></div>
<input type="button" value="Ok" onclick='okButtonClickListener();'/>
</BODY>
</HTML>
Thanks,
riog