Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6610649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:52:04+00:00 2026-05-25T19:52:04+00:00

Yo, Alright been noodling on this one for a while: How copy/cut styled text

  • 0

Yo,

Alright been noodling on this one for a while: How copy/cut styled text without bringing along any style baggage (background-color, color, etc)?

Couple of routes of attacks that have been foiled:

  1. Style the text differently using ::select? Doesn’t work, ::style isn’t copied
  2. Style the selected text using jQuery’s select binding This only works for inputs, not p, divs
  3. Intercept and remove style by binding an event to copy/paste using jQuery? Can’t access the copied object to remove stuff, tried using e.preventDefault(); then returning the event object but that didn’t work either
  4. Modify the clipboard data once it’s been saved? Also no dice, most browsers wont let you into this without flash and some sort confirmation

Anyway, thoughts? Seems like it would be very useful for sites that have white background colors.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:52:04+00:00Added an answer on May 25, 2026 at 7:52 pm

    I haven’t got time to code up an example now, but you could do this for cut/copy triggered by keyboard shortcuts. It wouldn’t work for cut/copy via context menu or Edit menu options because it relies on changing the user selection before the cut or copy event fires.

    The steps:

    1. Handle the Ctrl–C and Ctrl–X keyboard shortcuts and the Mac equivalents.
    2. In this handler, create an off-screen element (absolute position and left -10000px, say) and copy the selected content into it. You can do this using window.getSelection().getRangeAt(0).cloneContents(), although you’ll need separate code for IE < 9 and you should check the selection is not collapsed.
    3. Do whatever you like to to change the styling of the content of the off-screen element.
    4. Move the selection to encompass the content of the off-screen element so that it is this content that is cut or copied.
    5. Add a brief delay (a few milliseconds) using to window.setTimeout() that calls a function that removes the offscreen element and restores the original selection.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, so I have been wondering how to do this for a while. Basically,
Alright, this one's been puzzling me for a bit. the following function encodes a
Alright, I have been breaking my head over this one for more than a
Alright ive been bashing my head against the wall on this one for the
Alright, this has been on my mind for a while now. I'm in the
Alright, I've been working on this for a while and cannot get it. I'm
Alright, I'm not sure if this question has been asked before so if it
Alright, I know questions like this have probably been asked dozens of times, but
Alright, I'm at my wits end with this one. I am using an open-source
Alright so i have been working on this Dynamic load of a spinner from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.