Is there a way around the fact that does not seem to work in Google Docs? I want to capture text from a highlighted selection from Google Docs. My implementation is with Chrome Extensions, but that is not as relevant as the fact that window.getSelection() doesn’t seem to work there (though it does elsew…
Tag: javascript
Global variable in Web worker
I am using this Web worker which has a Global variable declared in it. Can I access the same (Global variable in worker 1) in the newly spawned web worker(worker 2)? When I’ve tried using jQuery in web worker, I get error “window is not defined”. Is there any way to use jQuery in a Web Worke…
Extract substring by utf-8 byte positions
I have a string and start and length with which to extract a substring. Both positions (start and length) are based on the byte offsets in the original UTF8 string. However, there is a problem: The start and length are in bytes, so I cannot use “substring”. The UTF8 string contains several multi-b…
Disable href with jquery/js
I am having difficulties in disabling href links through jquery. I am using this method I modified. Can some please advise or help me in figuring this out? Thank you. jquery/js html Answer You can use preventDefault(); to disable the default behaviour of links (which is, to navigate to the given href).
slideDown jumps abruptly at the end
I’ve built a fairly normal menu-submenu arrangement in a vertical column — nested ULs, using slideToggle to expand and collapse submenus. The problem I’m trying to solve is in the way the submenus “jump” open at the very end. (I’m testing in the latest release of Chrome.) I…
Convert a directory structure in the filesystem to JSON with Node.js
I have a file structure like this: I would like to, using Javascript and Node.js, listen to this root directory and all sub directories and create a JSON which mirrors this directory structure, each node contains type, name, path, and children: Here’s a coffeescript JSON: how to get this json data forma…
Simplest way to detect a pinch
This is a WEB APP not a native app. Please no Objective-C NS commands. So I need to detect ‘pinch’ events on iOS. Problem is every plugin or method I see for doing gestures or multi-touch events, is (usually) with jQuery and is a whole additional pluggin for every gesture under the sun. My applica…
JavaScript fileWatcher
I am developing a web application (intranet) and it is mandatory to watch a specific folder, for example c:docs, for inserted files. I would like to do that through JavaScript in order to detect each time the client inserts file into specific directory. Answer You can build your own application using django. …
Javascript event that runs before page changes
Is there such a thing? I know that I can hook my function on the click event of all links, but there are other situations where a page is changed, like refresh or when a different script changes the window.location In the end, I did it by sending a string trough postMessage from the unload event, like this: i…
How to detect radio button deselect event?
Is there an easy way to attach a “deselect” event on a radio button? It seems that the change event only fires when the button is selected. HTML JavaScript jsFiddle Answer Why don’t you simply create a custom event like, lets say, deselect and let it trigger on all the members of the click…