Property ‘dataset’ does not exist on type ‘EventTarget’

Problem is here Element, document, and window can be an EventTarget. You should detect your EventTarget if is an element. So in your case below code should work linkProvider = (ev: React.SyntheticEvent<EventTarget>) => { // If event target not an HTMLButtonElement, exit if (!(ev.target instanceof HTMLButtonElement)) { return; } console.debug(‘ev.target’, ev.target.dataset[‘ix’]) } In the short … Read more

How can I detect an address bar change with JavaScript?

HTML5 introduces a hashchange event which allows you to register for notifications of url hash changes without polling for them with a timer. It it supported by all major browsers (Firefox 3.6, IE8, Chrome, other Webkit-based browsers), but I’d still highly suggest to use a library which handles the event for you – i.e. by … Read more

How do I add and remove an event listener using a function with parameters?

Have you tried maintaining a reference to the anonymous function (like you suggested)? So: var listener = function() { check_pos(box); }; window.addEventListener(‘scroll’, listener, false); … window.removeEventListener(‘scroll’, listener, false); Mozilla’s docs suggest the same thing.

document.onclick vs window.onclick

The JavaScript Window object is the highest level JavaScript object which corresponds to the web browser window. The document object is the container for all HTML HEAD and BODY objects associated within the HTML tags of an HTML document. This could correspond to the top-most window, or an iframe within the window. Update After a … Read more

Create a file using Javascript in Chrome on client side

Sure you can, using the brand new APIs. window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; window.requestFileSystem(window.TEMPORARY, 1024*1024, function(fs) { fs.root.getFile(‘test.bin’, {create: true}, function(fileEntry) { // test.bin is filename fileEntry.createWriter(function(fileWriter) { var arr = new Uint8Array(3); // data length arr[0] = 97; // byte data; these are codes for ‘abc’ arr[1] = 98; arr[2] = 99; var blob … Read more