var myEvent = new Event('teaTime');
Остается положить конверт на нужный столик: document.getElementById('stolik').dispatchEvent(myEvent);
var event = new CustomEvent('saySomething', { detail: "Hello there!" });
(function(){
function ExitApi () {};
ExitApi.prototype.exit = function() {
console.log("Exit API: Close requested.")
};
ExitApi.prototype.delayCloseButton = function(e) {
if (e < 5) e = 5;
console.log("Exit API: Close Button will not appear for " + e + " seconds.")
};
var b = new ExitApi(),
method = "ExitApi",
_this = this;
if (!method in _this && _this.execScript) {
_this.execScript("var " + method);
}
if (!_this[method] || _this[method] === Object.prototype[method]) _this[method] = ExitApi;
}).call(this);
(function(){
function Foo () {};
Foo.prototype.exit = function() {
console.log("Exit API: Close requested.")
};
Foo.prototype.delayCloseButton = function(e) {
if (e < 5) e = 5;
console.log("Exit API: Close Button will not appear for " + e + " seconds.")
};
this.ExitApi = new Foo();
}).call(this);
Какие еще вопросы по безопасности нужно закрыть?
Насколько это безопасно и как защититься от подделок запросов в целом?
function toggleFullScreen(elem) {
if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
if (elem.requestFullScreen) {
elem.requestFullScreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullScreen) {
elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
}
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
}
user-select: none;
pointer-events: none;
<button class="addToCart" data-id="001">в массив 1</button>
<button class="addToCart" data-id="002">в массив 2</button>
<button class="addToCart" data-id="003">в массив 3</button>
<button class="addToCart" data-id="004">в массив 4</button>
var cart = {};
function addToCart(articul) {
cart[articul] = 1;
console.log(cart);
}
var addBtn = document.getElementsByClassName('addToCart');
[].forEach.call(addBtn, function(element) {
element.addEventListener('click', function() {
addToCart(this.getAttribute('data-id'));
});
});