Do you really want to leave this page ? – Confirmation popup window
window.onbeforeunload = function(){ return ‘Do you want to leave without saving changes’; }
window.onbeforeunload = function(){ return ‘Do you want to leave without saving changes’; }
function validateColor(color) { var el, result; el = document.createElement("div"); el.style.backgroundColor = "white"; document.body.appendChild(el); el.style.backgroundColor = color; result = el.style.backgroundColor; el.parentNode.removeChild(el); return color === "white" || result !== "white"; } validateColor(’white’);
The formula is very simple, and returns almost identic results (tested on OSX). size = (element_height / element_scroll_height) * element_height and similar for horizontal one: size = (element_width / element_scroll_width) * element_width In JS: var size = (el.offsetHeight / el.scrollHeight) * el.offsetHeight; In JS + JQ: var size = ($el.height() / el.scrollHeight) * $el.height();
Math.max.apply(null, [10, -1, 5]);//10
var arr = [1, 2]; Object.prototype.toString.call(arr) === "[object Array]"
Array.prototype.clone = function() { return this.slice(0); }
String.prototype.firstToUpperCase = function() { return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase(); }