What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-13 04:45:06
javascript touch scroll event
var lastTouch = null window.addEventListener('touchstart', function (event) { lastTouch = event.touches[0] }) window.addEventListener('touchend', function (event) { lastTouch = null }) window.addEventListener('touchmove', function (event) { var c... Add solution -
Javascript 2022-03-04 11:05:22
How to find out what character key is pressed?#key#keyCode#code
<table> <tr><td>Key:</td><td id="key"></td></tr> <tr><td>Key Code:</td><td id="keyCode"></td></tr> <tr><td>Event Code:</td><td id="... Add solution -
Javascript 2022-03-04 04:15:09
add update react pwa feature
//This from url https://stackoverflow.com/questions/56972246/how-to-update-reactjs-based-pwa-to-the-new-version window.addEventListener('activate', function(event) { event.waitUntil( caches.keys().then(function(cacheNames) { ... Add solution -
Other 2022-02-17 17:00:03
componentdidmount functional hook
import { useState, useEffect } from 'react'; function getWindowDimensions() { const { innerWidth: width, innerHeight: height } = window; return { width, height }; } export default function useWindowDimensions() { const [windowDimensions,... Add solution -
Javascript 2022-02-16 02:15:15
override print command javascript
function beforePrint() { console.log('Do something special before print'); } function afterPrint() { console.log('Do something after print'); } if (window.matchMedia) { window.matchMedia('print').addListener(function (mql) { if (mql.... Add solution -
Javascript 2022-02-14 06:40:07
javascript after dom ready
//two ways of executing JS code after page is loaded, use "DOMContentLoaded" when able document.addEventListener("DOMContentLoaded", function(){ //dom is fully loaded, but maybe waiting on images & css files }); window.... Add solution -
Other 2022-02-12 14:30:09
height form the top to the element
window.addEventListener('load', function() { //get the element var elem = document.getElementById('test'); //get the distance scrolled on body (by default can be changed) var distanceScrolled = document.body.scrollTop; //create viewport offset o... Add solution -
Javascript 2022-02-05 12:10:09
javascript emit event
//Listen for the event window.addEventListener("MyEventType", function(evt) { alert(evt.detail); }, false); //Dispatch an event var evt = new CustomEvent("MyEventType", {detail: "Any Object Here"}); window.dispatchEvent(... Add solution
Best helpers
Ranking is empty