I’m working on adding line number support to Rainbow, a syntax highlighter, but I can’t figure out how to make the line numbers uncopyable. Disabling selection via user-select: none; makes an element unhighlightable, but you can still copy its text by highlighting around it and then copying, which ends up copying the line numbers along with code. Here is a
Javascript trick for ‘paste as plain text` in execCommand
I have a basic editor based on execCommand following the sample introduced here. There are three ways to paste text within the execCommand area: Ctrl+V Right Click -> Paste Right Click -> Paste As Plain Text I want to allow pasting only plain text without any HTML markup. How can I force the first two actions to paste Plain Text?
Kinetic layer on top of Openlayers
I developed a canvas visualization of OpenStreetMaps by means of miscellaneous scripts and rendering algorithms from the internet. On top of this I have a Kinetic Stage which draws custom objects which cannot be drawn by the functionality of Openlayers. Openlayers provides many functions which I want to use and therefore I’m trying to switch over to this framework. I’m
Google Chrome extensions simple message passing error
I am trying to pass a message between my popup to a background page using the one message interface (I’m using code similar to the one in Google’s example for this). popup: and this is how I listen (and reply) in background.js: Now when I inspect everything in the console the messages are exchanged ok but I get the following
Print out Javascript array in table
I have this array: and I would like to print the entire array out as a html table. How would I accomplish this? I tried this but could only get the final name the print: Answer Using jQuery you can do: jsFiddle: http://jsfiddle.net/davidbuzatto/aDX7E/
How to click an element in Selenium WebDriver using JavaScript?
I have the following HTML: My following code for clicking “Google Search” button is working well using Java in WebDriver. I want to use JavaScript with WebDriver to click the button. How can I do it? Answer Executing a click via JavaScript has some behaviors of which you should be aware. If for example, the code bound to the onclick
Put javascript and css inline in a single minified html file to improve performance?
A typical website consists of one index.html file and a bunch of javascript and css files. To improve the performance of the website, one can: Minify the javascript and css files, to reduce the file sizes. Concatenate the javascript files into one file and similar for the css files, to reduce the number of requests to the server. For commonly
How to create a login page for a user that checks their password on the client side
How do I create a login page that checks for a correct password on the client side and goes to the next screen if the password is correct? Here is my attempt: Answer
Javascript string-replace function ignoring hyphen
I have the following code: The alert gives hello,,..there I would expect it to give hello—,,..there as all the characters, including hyphens, are specified as exceptions in the replacement function. What am I doing wrong? Answer Escape the hyphen:
Javascript disabling Div element on submit
The code below just hides the movie that I am playing behind. Remove element (if possible) or disable it, specially movie playing in background. I tried using document.video.disabled=true; but its not working. Any idea how to go around this problem please? Answer Try