<div id="btnSideToggle" onclick="Viewer.toggleThumbnails();"><img src="assets/pgThumbs.png"></div>
Due to CSP restriction on Firefox OS Marketplace i cant use onclick on html5 page, can anyone please tell me alternative of onclick for HTML5
here is the full code : http://jsfiddle.net/edd4225/v65qZ/
This will work for you
var button = document.querySelector("#btnSideToggle");
button.addEventListener("click", function onclick(event) {
Viewer.toggleThumbnails();
event.preventDefault();
});
You could simplify it with Function.prototype.bind
(requires ECMAScript >= 5
)
button.addEventListener("click", Viewer.toggleThumbnails.bind(Viewer));
Note that an Event
will still be sent as the first argument to the toggleThumbnails
handler.