Help - Search - Members - Calendar
Full Version: Auto Select and Copy
HTMLHelp Forums > Programming > Client-side Scripting
denmarks
I have a page that is only used by me and is located on my computer. There is an index at the top with descriptions. When a description is clicked the page repositions using <a> tags to a paragraph with the details. The paragraph is surrounded with the <span> tag.

Is there a way to have the text within the paragraph selected and copied when the index item is clicked to get to the paragraph? I always drag through the data and copy. It would be nice to have it automated if possible.
Christian J
In IE you can use java script:

CODE
<a href="#a" onclick="window.clipboardData.setData('Text', document.getElementById('a').firstChild.nodeValue);">link</a>
<span id="a">foo</span>


assuming the SPAN contains no markup, just plain text, and assuming your security settings permit reading/writing to your clipboard (not recommended on the www for privacy reasons). Other browsers don't support it.

denmarks
QUOTE(Christian J @ Jan 17 2008, 06:50 PM) *

In IE you can use java script:

CODE
<a href="#a" onclick="window.clipboardData.setData('Text', document.getElementById('a').firstChild.nodeValue);">link</a>
<span id="a">foo</span>


assuming the SPAN contains no markup, just plain text, and assuming your security settings permit reading/writing to your clipboard (not recommended on the www for privacy reasons). Other browsers don't support it.


Thank you but I need it for Firefox. Any other possibilities?
Christian J
Googling turns up some ideas (that I haven't tested), but they seem to require changes to Firefox: http://www.mozilla.org/projects/security/c...ed-scripts.html
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.