Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Jul 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how would i highlight and copy a textarea?

    i want a function to copy a textarea named affiliate, so when i click a button it is highlighted and copied to the clipboard, how would i go about doing this?

    basically, this is what i want to happen:

    <A href="javascript:HighlightAffiliate()">
    <img src="http://img.photobucket.com/albums/v257/sucramreverse/minibanner.gif" border="0"></A>
    <BR>
    <TEXTAREA name=Affiliate rows=1 cols=1 style="filter: alpha(opacity=0);><a href="http://pixelgrafx.proboards33.com">
    <img src="http://img78.photobucket.com/albums/v257/sucramreverse/minibanner.gif">
    </a>
    </textarea>

    basically, I would like to know what to use for the function HighlightAffiliate(), I don't really know it and im new to JS
    Last edited by dmsuperman; 08-11-2004 at 10:37 PM.

  • #2
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Helping to build a bigger box. - Adam Matthews

  • #3
    New Coder
    Join Date
    Jul 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ty alot, i knew it was simple just didnt know what it was

  • #4
    New Coder
    Join Date
    Jul 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, this is the entire code, i dont know why its not working:

    <script language="JavaScript">
    <--
    function ClipBoard()
    {
    holdtext.innerText = copytext.innerText;
    Copied = holdtext.createTextRange();
    Copied.execCommand("Copy");
    alert("Affiliate code copied!");
    }

    //-->
    </script>
    <div align=center><br><BR>
    <SPAN ID="copytext" STYLE="display:none;">
    <a href="http://pixelgrafx.proboards33.com">
    <img src="http://img78.photobucket.com/albums/v257/sucramreverse/minibanner.gif">
    </a>
    </SPAN>
    <TEXTAREA ID="holdtext" STYLE="display:none;">
    </TEXTAREA>
    <A href="javascript:ClipBoard();">
    <img src="http://img.photobucket.com/albums/v257/sucramreverse/minibanner.gif" border="0"></A>
    <BR>
    </div>
    what did i do wrong?

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not only is that IE only but many of the recent Critical Updates have disabled Allow paste operations via script....

    Check Tools --> Internet Options --> Security --> Custom Level to see if this option has been disabled on your machine. Even if it is not, don't expect that it will not be disabled on any other machine since the recent release of SP2 also disables this option by default....

    .....Willy

  • #6
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Here ya go,

    Code:
    <html>
    <head>
    <script language="JavaScript">
    function ClipBoard() 
    {
    holdtext.innerText = copytext.innerText;
    Copied = holdtext.createTextRange();
    Copied.execCommand("Copy");
    alert("Affiliate code copied!");
    }
    </script>
    </head>
    <body>
    <div align=center><br><BR>
    <SPAN ID="copytext" STYLE="display:inline;">
    This is the text to be copied.
    </SPAN>
    <br>
    <TEXTAREA ID="holdtext" STYLE="display:none;">
    </TEXTAREA>
    <A href="javascript:ClipBoard();">
    Click here to copy text above.</A>
    <BR>
    </div>
    </body>
    </html>
    Basscyst
    Helping to build a bigger box. - Adam Matthews

  • #7
    New Coder
    Join Date
    Jul 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i dunno whats up
    i know i can copy to clipboard from another cuz it works other places
    anyway, i wonder if there is anyway so i dont have textareas cuz i just have some certain text that i dont want them to see but i want it to be copied to the clipboard when they hit a button, if this makes it easier
    i have some code that i want to be copied to the clipboard when they click the link
    is there anyway to do it like this:
    <script>
    function Highlight(){
    copy = "<a href="http://pixelgrafx.proboards33.com">
    <img src="http://img78.photobucket.com/albums/v257/sucramreverse/minibanner.gif" border=0>
    </a>"
    alert("Code copied!");
    }
    </script>
    <a href="javascript:Highlight();">Click to copy code</a>
    if this would make it easier that would be good, but the other one doesnt work for some reason
    Last edited by dmsuperman; 08-11-2004 at 11:45 PM.

  • #8
    New Coder
    Join Date
    Jul 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    could someone help me out?

  • #9
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've already explained that this is a security threat which Mozilla addressed long ago and thankfully Microsoft is finally getting around to fixing. Thus, what you are trying to do is an exercise in futility. Even it you get it to work on your machine, it will not work on the majority of other machines. And even if it works on another machine today, it will not work once they become updated with SP2...

    Quit trying to hide the text you want the user to copy and display this text in a textarea using the READONLY attribute to prevent them from editting the content....

    ......Willy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •