Try using Javascript below:
(function () {
var fsicon = document.createElement('img');
var srcFSI = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAI1JREFUeNrsV0EOwCAI6w/8/6lP8gk8ZTuPLUoirltCEy8mpY0iIAAcg0WsgxONreIRE4+bhnzYr05AkgO2wQQHV3wxwAmBieJe6xY8w0Q0BlcDZHOngXqA1zPziE68BTjNmWDGM4qKexNEoVAoJPVzWSGSlmJpM3q1HcsHEvlI9omhtL5m9TWT5cApwAD/IigEZttSgAAAAABJRU5ErkJggg==';
var srcFSIexit = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABVQTFRFAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgEApAAAAAZ0Uk5TAA+fz9/vpTOW9gAAAJNJREFUKM/NkkEKwyAUBSeeQOoFDAX3duERcoQcQJN3/yN08RVLUui2fyE4Ph/IyPLiY56eoDj3TpmiOkFSI2lEPE6qtgSA3A+TtBaA9pAq4KRTANr77SQZUO93E1j9sg9wegDCTGQAygTN80fz+3FsAxx8T1w7nHQY2CySpJgAqpMq3QVANA3mwo/6eld5k339Dm89PDdxiEGVaQAAAABJRU5ErkJggg==';
fsicon.src = srcFSI;
fsicon.id = 'fsicon';
fsicon.style.opacity = 0.5;
fsicon.style.filter = 'alpha( opacity=50 )';
fsicon.style.cursor = 'pointer';
fsicon.style.zIndex = 2000;
fsicon.style.top = '10px';
fsicon.style.right = '10px';
fsicon.style.position = 'fixed';
document.body.appendChild(fsicon);
var fsicon = document.getElementById("fsicon");
if (fsicon) {
fsicon.addEventListener("click", function () {
if(fsicon.getAttribute('src')!=srcFSIexit){
var docElm = document.documentElement;
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
}
else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
}
else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
}
}else{
if (document.exitFullscreen) {
document.exitFullscreen();
}
else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}
}, false);
}
if (fsicon) {
document.addEventListener("fullscreenchange", function () {
if(document.fullscreenElement){
fsicon.setAttribute('src',srcFSIexit);
}else{
fsicon.setAttribute('src',srcFSI);
};
}, false);
document.addEventListener("mozfullscreenchange", function () {
if(document.mozFullScreen){
fsicon.setAttribute('src',srcFSIexit);
}else{
fsicon.setAttribute('src',srcFSI);
};
}, false);
document.addEventListener("webkitfullscreenchange", function () {
if(document.webkitIsFullScreen){
fsicon.setAttribute('src',srcFSIexit);
}else{
fsicon.setAttribute('src',srcFSI);
};
}, false);
}
})();
Perfect! thank you very much.
– Renan
@Renanosorio Your feedback is very important to people who want to help!! Tell me, it worked on your project?
– RXSD
Yeah, I’ve implemented it, it worked fine. But since you asked, there is a bug in the logic that I did, which is the following, when I click the button I give an Hide in my main menu, when I click again I give a show in the menu, until then quiet, but if I click and give Hide in the menu and then give an ESC on the keyboard, the menu is still in Hide. I’ll publish the logic here as soon as possible.
– Renan
here is the code (https://codepen.io/anon/pen/GYmrry), I searched the internet but could not find the solution, if you know let me know. until.
– Renan
@Renanosorio just add this function below: Document.onkeydown = Function(evt) { evt = evt || window.Event; if (evt.keycode == 27) { Document.getElementById("item").style.display = 'block'; } }; //It checks whether the 27 - 'Escape' or better known 'Esc' button is pressed, when pressed, changes the style of the #Item. If this comment was also useful, add the arrow for this comment and the previous one I did just to give a strength, okay? Valeu.
– RXSD
Tell me if you got what you wanted @Renanosorio.
– RXSD
I couldn’t, look at the code I made. https://codepen.io/anon/pen/zmwwLX
– Renan
Bro, just add that snippet of code to the same function I sent you earlier. I’m sending you this text from the phone, but I’ll send you the code tomorrow in the codeopen. I did exactly what you needed in a few lines of code, very simple.
– RXSD
@Renanosorio , then puts the answer as the main one, it makes people with the same doubt immediately find my answer, which was the clearest for you. Hugs!
– RXSD