Copy text from HTML page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Vick

    #1

    Copy text from HTML page

    OK, I've got a requirment to copy some content from an HTML page. It is
    a failry lengthy page and we want to give the user/reader the ability to
    click a button and have a section of the page copied to the clipboard,
    or at the very least selected so they can just right click and copy it.
    The issue is that text/content to be selected/copied is not in a textarea.

    I've got it in a div right now and can get the innerHTML of the div and
    set a text area to that but it comes in with all of the HTML tags and so
    when I copy it to notepad I get all of the tags which is what I dont want.

    Has anyone done this before? I've tried numerous things to get it to
    work and have had no luck.

    Thanks in advance.

    Dave
  • VK

    #2
    Re: Copy text from HTML page

    did you try innerText instead of innerHTML?


    Comment

    • Dave Vick

      #3
      Re: Copy text from HTML page

      VK wrote:[color=blue]
      > did you try innerText instead of innerHTML?
      >
      >[/color]
      The innerTest of a div (and a span) is undefined. :(

      Comment

      • Andrew Thompson

        #4
        Re: Copy text from HTML page

        On Fri, 01 Oct 2004 11:05:08 -0400, Dave Vick wrote:
        [color=blue]
        > VK wrote:[color=green]
        >> did you try innerText instead of innerHTML?
        >>[/color]
        > The innerTest of a div (and a span) is undefined. :([/color]

        ...what about the innerTe*x*t?

        --
        Andrew Thompson
        http://www.PhySci.org/codes/ Web & IT Help
        http://www.PhySci.org/ Open-source software suite
        http://www.1point1C.org/ Science & Technology
        http://www.lensescapes.com/ Images that escape the mundane

        Comment

        • Dave Vick

          #5
          Re: Copy text from HTML page

          Andrew Thompson wrote:
          [color=blue]
          > On Fri, 01 Oct 2004 11:05:08 -0400, Dave Vick wrote:
          >
          >[color=green]
          >>VK wrote:
          >>[color=darkred]
          >>>did you try innerText instead of innerHTML?
          >>>[/color]
          >>
          >>The innerTest of a div (and a span) is undefined. :([/color]
          >
          >
          > ..what about the innerTe*x*t?
          >[/color]
          :) Yes the innerText is undefined too :)

          Comment

          • Randy Webb

            #6
            Re: Copy text from HTML page

            Dave Vick wrote:[color=blue]
            > OK, I've got a requirment to copy some content from an HTML page. It is
            > a failry lengthy page and we want to give the user/reader the ability to
            > click a button and have a section of the page copied to the clipboard,
            > or at the very least selected so they can just right click and copy it.
            > The issue is that text/content to be selected/copied is not in a textarea.
            >
            > I've got it in a div right now and can get the innerHTML of the div and
            > set a text area to that but it comes in with all of the HTML tags and so
            > when I copy it to notepad I get all of the tags which is what I dont want.
            >
            > Has anyone done this before? I've tried numerous things to get it to
            > work and have had no luck.
            >[/color]

            Create a range, select it, copy it. Google the newsgroup archives. And
            yes, I have done it before.

            --
            Randy
            comp.lang.javas cript FAQ - http://jibbering.com/faq

            Comment

            Working...