Make a TEXT SELECTION
-
I have text in my webpage and I want to make a simple Buton that on click : selects, copy all the text on clipboard, and finally deselects all or at least just selects all I think it´s very simple using JavaScript but I cant get it any comments ? THANX ¡¡¡ Armando Monterrey, Mexico
-
I have text in my webpage and I want to make a simple Buton that on click : selects, copy all the text on clipboard, and finally deselects all or at least just selects all I think it´s very simple using JavaScript but I cant get it any comments ? THANX ¡¡¡ Armando Monterrey, Mexico
Hi there, IMO, just simple getting the selected text from the textbox control and do paste the selected text into clipboard by using this statement window.clipboardData.setData("Text",selectedText); << >>
-
I have text in my webpage and I want to make a simple Buton that on click : selects, copy all the text on clipboard, and finally deselects all or at least just selects all I think it´s very simple using JavaScript but I cant get it any comments ? THANX ¡¡¡ Armando Monterrey, Mexico
I hate Internet-Explorer-only solutions; however, here's one for you:
var r = document.body.createTextRange();
r.select();
r.execCommand( "copy" );If you want a cross-browser implementation, may I suggest reading the innerHTML property of
document.body
and using regular expressions to remove any tags. "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty -
Hi there, IMO, just simple getting the selected text from the textbox control and do paste the selected text into clipboard by using this statement window.clipboardData.setData("Text",selectedText); << >>
I tried by using this " onClick="javascript:select();" " but it only selects the text that is into the button not the text on the webpage And I didnt get the idea you gave me so could you give another one using my example?
-
I tried by using this " onClick="javascript:select();" " but it only selects the text that is into the button not the text on the webpage And I didnt get the idea you gave me so could you give another one using my example?
where is the text you put it into (textbox or textarea control)? or do you want to copy whole page? << >>
-
where is the text you put it into (textbox or textarea control)? or do you want to copy whole page? << >>
I want to copy the whole page, My page doesnt have any pics, only text thanx ¡
-
I have text in my webpage and I want to make a simple Buton that on click : selects, copy all the text on clipboard, and finally deselects all or at least just selects all I think it´s very simple using JavaScript but I cant get it any comments ? THANX ¡¡¡ Armando Monterrey, Mexico
Found this on the web. It copies the selection in a drop-down to the clipboard. Could probably be modified to copy other text on the page: function copyText(theSel) { if (!document.all) return; // IE only theForm = theSel.form; theForm.copyArea.value=theSel.options[theSel.selectedIndex].value; r=theForm.copyArea.createTextRange(); r.select(); r.execCommand('copy'); }
Please select A B
"Half this game is ninety percent mental." - Yogi Berra
-
I want to copy the whole page, My page doesnt have any pics, only text thanx ¡
Just a suggestion, but IMO it's not the best ;P save the page's content into a hidden field before generating the page. Then, when user clicks on the button, just copy the value of the hidden field to the clipboard. Hope it gives u an idea... << >>