Click to See Complete Forum and Search --> : Auto copy or select within an Iframe
Code One
03-29-2003, 03:33 AM
Hello,
I was wondering if anyone knew how to set up a script that would allow me to either auto copy, or auto select the contents within an Iframe, which would be text? I would like to be able to do this if possible by either clicking within the Iframe, or a button out side of the Iframe. If anyone could show me a way to do this it would be much appreciated!
Thanks in advance!
Code One
Ice3T
03-29-2003, 09:43 PM
Well ummm if you put a textarea in your inline frame and use: onMouseOver(this.select) in that textarea
and then you can make most of the textarea disaper with css and then for the scrollbar area of that textarea you just have to make the textarea more wide than the inlineframe so that it wont show and make shur to select no scrollbars for the inline frame.
I dont know about other browsers but in IE6 it looks good.
Code One
03-29-2003, 11:16 PM
But unfortunatly I have to keep it as an Iframe because I have a feature that loads text files into it, and I tried doing the same with textarea and input, but it seems to work only with iframes, and frames. So this is what Im doing instead, in my quick reference guide Im telling users to just click within the iframe to give it focus and then to simply press ctrl + a, to highlight text, then to press ctrl + c, to copy, and then to move up to the textarea click to give focus, and then press ctrl + v, to paste. Seems long but it is actually quite faster than right clicking, and once you get the hang of it the problem becomes a feature.
Thanks just the same though! :)
Code One
Ice3T
03-29-2003, 11:25 PM
At least if you cannot use a textarea in your inlineframe you could use onMouseOver(this.focus()) to save your users the click in the frame step.
Code One
03-29-2003, 11:55 PM
I bet the user will still click in it though, hahaha. It might become a waisted code on many but I think it would be atleast helpful to some. I think Im going to add it on in.
Thanks for the idea!
Code One
Can't you use execCommand("Copy") ?
I've used it before to copy text from a textarea. You can also use execCommand("Paste") to paste it back in. I haven't got the code handy - its on another computer, but if you look it up on the web I'm sure you'll be able to work out how to use it.
IxxI
Ice3T
03-30-2003, 08:08 AM
I dont think that will work in an iframe contaning a text file (*.txt)
But once you have manually copied text from your text file you could use onMouseOver="this.focus(),execCommand('Paste')"> on that textarea you want your user to past it to. Also you may want to put it in a if branch so that it will only past if the textarea value is "" (nothing) so that the user does not past it more than once.
Code One
03-30-2003, 03:16 PM
This is my 100th post!!!!!! I've waited so long for this day sniff sniff . . .
All right let me ask you this can I just put that command right into my textarea or do I have to slap together a script?
Code One
Code One
03-30-2003, 03:30 PM
I checked out the code and the the auto paste works and instead of making a script and including (if) I went ahead and changed the command to ondblclick, because I have the auto copy in the textarea as well and it works on just one click, so I figured why not right? I trid the auto copy in the iframe and thats a negative.
Thanks for all the help gentlemen
Code One