1

Does anyone know how to copy text to clipboard from a h1 but text formating should be the same and no html attributes should appear

Comments
  • 1
    I'd say you loop through the elements and append the inner text to a string, but then there's your odd requirement for "keepkng text formatting the same".
  • 0
    @kescherRant yea i have to keep the text as it is shown to the user .
  • 1
    A while ago some websites modified the text copied (e.g. by adding ads or something like "copied from...") by doing following:
    Detect what text is selected, create a new element with the text (in your case without formatting) override the selection and put to clipboard, restore the selection.

    Wouldn't it be easier to tell the user to do Ctrl+Shift+V when pasting?
  • 0
    @sbiewald what if the user is using a mobile device . what then
  • 0
    Even if I copy from vscode it includes the formatting of my syntax highlighting. That blows.
  • 0
    @PublicByte what
  • 0
    @PublicByte havent you checked the qs properly
  • 0
    @PublicByte qs = question that i have posted
  • 0
    @PublicByte programatically
Add Comment