What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-12 02:07:19
detect back button press javascript
So as far as AJAX is concerned... Pressing back while using most web-apps that use AJAX to navigate specific parts of a page is a HUGE issue. I don't accept that 'having to disable the button means you're doing something wrong' and in fact developers in ... Add solution -
Javascript 2021-11-11 14:05:11
javascript show popup on page refresh unsaved changes
var onReloadCheck = function () { $(window).on('beforeunload', function () { var modal = $('#myModal').hasClass('show'); if (modal) { return "If you leave before saving, your changes will be lost."... Add solution -
Javascript 2021-11-10 07:20:15
prototype javascript
function Animal (name, energy) { this.name = name this.energy = energy } Animal.prototype.eat = function (amount) { console.log(`${this.name} is eating.`) this.energy += amount } Animal.prototype.sleep = function (length) { console.log(`${this... Add solution -
Javascript 2021-11-10 03:43:09
pure javascript post request
var xhr = new XMLHttpRequest(); // we defined the xhr xhr.onreadystatechange = function () { if (this.readyState != 4) return; if (this.status == 200) { var data = JSON.parse(this.responseText); // we get the returned data }... Add solution -
Javascript 2021-11-05 10:16:14
random id js
var ID = function () { // Math.random should be unique because of its seeding algorithm. // Convert it to base 36 (numbers + letters), and grab the first 9 characters // after the decimal. return '_' + Math.random().toString(36).substr(2, 9); }; Add solution -
Javascript 2021-10-29 17:43:13
function resizeBase64Img(base64, newWidth, newHeight) { return new Promise<string>((resolve, reject)=>{
/** * Resize a base 64 Image * @param {String} base64 - The base64 string (must include MIME type) * @param {Number} newWidth - The width of the image in pixels * @param {Number} newHeight - The height of the image in pixels */ function resizeBase64I... Add solution -
Javascript 2021-10-29 13:05:12
javascript circular evaluation
Game.prototype.restart = function () { this.clearLocalStorage(); this.timer = setTimeout(this.reset.bind(this), 0); // bind to 'this' }; Game.prototype.reset = function(){ this.clearBoard(); // ahhh, back in the context of the right 'this'! }; Add solution
Best helpers
Ranking is empty