Results 1 to 5 of 5

Thread: [Request] HTML code for disable some selection text but remain some selection area?

  1. #1
    Join Date
    Jan 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question [Request] HTML code for disable some selection text but remain some selection area?

    I see some website can disable selection text on some body post. But remain some text that can still be selected. Like writing post can not be selected for protecting that content, but html code can be selected for share.
    How they can to do that?

    Thanks.
    didla08

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,030
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Please provide an example website that exhibits this behaviour.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    Jan 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Actually i found 3 blogs can do that. But i just remember 1. here: http://helplogger.blogspot.com/2012/...nails-for.html
    Their text can not be copied but the html code can be copied. I search in google but i don't get the right answer. Maybe you can help me out sir.

  4. #4
    Join Date
    Aug 2009
    Location
    utf-8
    Posts
    205
    Thanks
    4
    Thanked 7 Times in 7 Posts

    Default

    Try this JavaScript
    Code:
    <script>
    if (typeof document.onselectstart!="undefined") {
      document.onselectstart=new Function ("return false");
    }
    else{
      document.onmousedown=new Function ("return false");
      document.onmouseup=new Function ("return true");
    }
    </script>
    Or with CSS, however it may not work on some browsers. Use JavaScript for more availability.
    Code:
    .un-select-able {
      -webkit-user-select: none;  /* Chrome all / Safari all */
      -moz-user-select: none;     /* Firefox all */
      -ms-user-select: none;      /* IE 10+ */
    
      /* No support for these yet, use at own risk */
      -o-user-select: none;
      user-select: none;          
    }
    An inline div is a freak of the web and should be beaten until it becomes a span

  5. #5
    Join Date
    Jan 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you sir for your help.
    i've tried and it is working.

Similar Threads

  1. Replies: 6
    Last Post: 12-13-2012, 09:52 PM
  2. Help with Disable Text Selection script
    By snoopygirl11 in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-26-2009, 09:03 PM
  3. Disable right click and text selection blogger?
    By smoothfreeze in forum JavaScript
    Replies: 3
    Last Post: 12-02-2008, 04:51 AM
  4. Disable Text Selection
    By sourabhmca in forum JavaScript
    Replies: 0
    Last Post: 11-28-2007, 05:52 PM

Bookmarks

Posting Permissions

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