<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8211560\x26blogName\x3dTech+Tips,+Tricks+%26+Trivia\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://mvark.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttps://mvark.blogspot.com/\x26vt\x3d4840557131965418185', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Tech Tips, Tricks & Trivia

by 'Anil' Radhakrishna
An architect's notes, experiments, discoveries and annotated bookmarks.

HOW TO turn off copy-pasting restrictions on web form fields of annoying websites

Some sites disallow pasting values into text boxes within a form. This can be annoying if the content that is to be copied is a very long or is so cryptic that you have to copy it from somewhere else carefully character by character.

Some websites implement it using the onpaste event:
<input class="yellowtextbox" name="txtCustomerID1" maxlength="10" onpaste="return false;">

Derek Prior has written a bookmarklet that deactivates the functionality that prevents values from being pasted into text fields. Copy the bookmarklet to your browser's bookmarklet bar and click on it while you're on the annoying web page that disables pasting values.

His code works for password fields. It can be made to work for input fields like textboxes as well by commenting a couple of lines.

var inputs = document.getElementsByTagName('input');
for (var i=0; i < inputs.length; i++) {
 // if (inputs[i].getAttribute('type').toLowerCase() === 'password') {
    inputs[i].setAttribute('onpaste', '');
//  }

Chris Bailey has improved code that can work on web forms which have this feature implemented not declaratively as in the above case but through JavaScript or jQuery.

This is a bit of a hassle but another alternative is to disable JavaScript temporarily for that page which will in turn will turn off the JavaScript paste blocker. For Chrome, the keyboard shortcut to open Dev Tools is F12, to reach the Settings panel is F1 & here you'll find the checkbox to Disable JavaScript in the General section.
The idea of neutralizing an event within an external page through code in a bookmarklet can be extended to other scenarios.

Some websites take text selected by a user within a page & show some UI effect like a balloon, tooltip or an alert with content related to the selected text. If the purpose of that effect doesn't improve the reading experience, it can be gotten rid off.

For example, this implementation shows an alert with selected text when a user selects text as that action is bound to the mouseup event. I was able to disable that effect by using this bookmarklet code that unbinds the mouseup event:

javascript:(function(){ $(document).unbind('mouseup')})();

As the way that functionality is implemented on each site can vary (the function to trigger an alert/pop up could be tied to a specific paragraph or div and that too with a different event), writing a generic solution to disable that effect through a single bookmarklet can be challenging as it has take care of the different ways that feature is implemented.

Related: Dictionary Bookmarklet

Labels: , ,

Tweet this | Share via Whatsapp | Share on FB

« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »


Post a Comment