Enabling blocked text selection using JavaScript

Agree with jfriend00. It's good to avoid those problem website. Unless if it's really necessarily to stock to the site... Then you might consider trying this:

Disable browser Java Script for the problem website might work too. http://browsers.about.com/od/googlechrome/ss/disable-javascript-chrome-windows.htm


Had the same issue with a website.

CSS can't solve this problem as Javascript comes into play whenever you try to select the text.

There are two ways to solve this 1) Disable Javascript on your web browser. Check this out for reference. http://browsers.about.com/od/googlechrome/ss/disable-javascript-chrome-windows.htm 2) Open the javascript console. I am using chrome (click shift+command+C on Mac, f12 on Ubuntu and Windows)

copy this code document.body.onselectstart = function() {return true;}; and paste it in the console, and hit enter.


Check out the Enable All Text Selection bookmarklet by Alan Hogan. The only issue with the bookmarklet is that it does not handle frames/iframes (that's a browser security thing so it's unlikely something can be done about it).

As an added bonus, it also enables the mouse right-click event on pages that block it.

Create a bookmark (e.g. by dragging the icon to the left of the URL for any page to your bookmarks bar), right-click and select Edit, rename to something meaningful, and insert the following code in the URL field:

javascript:(function(){function%20allowTextSelection(){window.console&&console.log('allowTextSelection');var%20style=document.createElement('style');style.type='text/css';style.innerHTML='*,p,div{user-select:text%20!important;-moz-user-select:text%20!important;-webkit-user-select:text%20!important;}';document.head.appendChild(style);var%20elArray=document.body.getElementsByTagName('*');for(var%20i=0;i<elArray.length;i++){var%20el=elArray[i];el.onselectstart=el.ondragstart=el.ondrag=el.oncontextmenu=el.onmousedown=el.onmouseup=function(){return%20true};if(el%20instanceof%20HTMLInputElement&&['text','password','email','number','tel','url'].indexOf(el.type.toLowerCase())>-1){el.removeAttribute('disabled');el.onkeydown=el.onkeyup=function(){return%20true};}}}allowTextSelection();})();

To make the bookmarklet code readable you can use the Bookmarkelt Builder at http://subsimple.com/bookmarklets/jsbuilder.htm - just paste the minified bookmarklet text and click the Format button.


if you are on google chrome you can use this extension

https://chrome.google.com/webstore/detail/enable-selection/jehoagbopeaefibnihnfgenfcilmcikj/

It enables text selection and the right click if it's blocked

Tags:

Javascript

Css