Passer en plein écran en javascript
Alors que je développais son application web, un client m'a demandé si on pouvait passer le navigateur en plein écran.
J'allais lui conseiller une simple pression sur la touche F11 mais je savais pertinemment qu'il l'oublierait vite et qu'il me reposerait la question quelques semaines plus tard.
Loin des yeux, loin du cœur, j'ai vite compris que les humains avaient besoin d'avoir l'outil devant les yeux pour penser à l'utiliser.
Voici donc quelques lignes de codes en javascript, couplées à un simple bouton en HTML (dans l'exemple, j'ai utilisé "Fontawesome"), permettant le passage d'un navigateur en plein écran.
Le code javascript:
/** * Toggle fullscreen fonctionne avec les navigateurs webkit et firefox. * @function toggleFullscreen * @param {Object} event */ function toggleFullscreen(event) { var element = document.body; var fsbutton = document.getElementById('toggle'); if (event instanceof HTMLElement) { element = event; } var isFullscreen = document.webkitIsFullScreen || document.mozFullScreen || false; element.requestFullScreen = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || function () { return false; }; document.cancelFullScreen = document.cancelFullScreen || document.webkitCancelFullScreen || document.mozCancelFullScreen || function () { return false; }; if ( isFullscreen ) { document.cancelFullScreen(); fsbutton.classList.remove('fa-compress-arrows-alt'); fsbutton.classList.add('fa-arrows-alt'); } else { element.requestFullScreen(); fsbutton.classList.remove('fa-arrows-alt'); fsbutton.classList.add('fa-compress-arrows-alt'); } }
Le code HTML:
<a href="#" onclick="toggleFullscreen(); return false;"><span><i id="toggle" class="fa fa-arrows-alt"></i></span></a>
Évidemment, inutile d'appliquer ce code si votre application nécessite un chargement de page lequel vous ferait immédiatement quitter le plein écran.
Dans mon cas, toute l'application fonctionnait en Ajax et donc sans rechargement/rafraichissement de la page active.
Commentaires
This website definitely has all of the information I needed about this subject and
didn't know who to ask.
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
Hello friends, its fantastic post on the topic of tutoringand completely
defined, keep it up all the time.
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
nolvadex para ginecomastia <a href="https://nolvadexsrm.com/ ">nolvadex progesterone gyno</a> nolvadex women cycle https://nolvadexsrm.com/
glucophage effets indГ©sirables <a href="https://metforminukx.com/ ">metformin testosterone production</a> metformin titration schedule https://metforminukx.com/
atenolol hyperlipidemia <a href="https://tenorminscx.com/ ">atenolol bei hunden</a> tenormin reviews anxiety https://tenorminscx.com/
synthroid and ephedra <a href="https://synthroidsdu.com/ ">synthroid speed</a> excipientes de synthroid https://synthroidsdu.com/
pregabalin savings <a href="https://lyricaxol.com/ ">cymbalta or lyrica for neuropathy</a> cymbalta and lyrica together for nerve pain https://lyricaxol.com/
gabapentin 1500mg <a href="https://gabapentinujv.com/ ">gabapentin sublingual</a> neurontin zamiennik https://gabapentinujv.com/
Hey there would you mind letting me know which webhost you're utilizing?
I've loaded your blog in 3 different web browsers and I must say this
blog loads a lot quicker then most. Can you recommend a good internet hosting provider at a fair price?
Cheers, I appreciate it!
lasix chien <a href="https://lasixrcj.com/ ">furosemide monografia</a> thoroughbred lasix
metformin adhd <a href="https://metforminyhx.com/ ">metformin cukorbetegsГ©g</a> metformin ohss
nolvadex doz <a href="https://nolvadexsry.com/ ">wadenkrämpfe tamoxifen</a> dostinex tamoxifen
guna furosemide <a href="https://lasixrcj.com/ ">lasix similares</a> furosemide cavalier
synthroid brasil <a href="https://synthroiddho.com/ ">synthroid epocrates</a> synthroid 66
mГ©dicaments furosemide <a href="https://lasixrcs.com/ ">furosemide scheda</a> furosemide breathlessness
lipitor flushing <a href="https://lipitorsry.com/ ">cqs.com/lipitor.htm</a> lipitor hart
lipitor ppt <a href="https://lipitorsrt.com/ ">lipitor subclass</a> atorvastatin caduet
gabapentin generic neurontin <a href="https://gabapentinyux.com/ ">abuse gabapentin</a> gabapentin ghb
5 paragraph essay <a href="https://essayslurrily.net/ ">essay editor service</a> free essay writer program
easy essay help <a href="https://essaysluice.org/ ">how to cite an essay</a> example of an analytical essay
essay writer helper <a href="https://essaywritermla.com/ ">states synonym for essay</a> essay writer service
conclusion of an essay <a href="https://essayexpo.net/ ">how to quote a quote in an essay</a> essay writting services
how to quote a quote in an essay <a href="https://essaysludge.net/ ">college essay tips</a> essay writers net
can t write my essay <a href="https://essayslues.org/ ">how to start an essay introduction</a> scholarship essay examples
writing a college paper <a href="https://writepaperrichness.net/ ">fancy letter writing paper</a> writing without tears paper
dissertation editor rates <a href="https://servicedissertationspps.com... ">proquest dissertation search</a> masters dissertation example
strathmore writing paper <a href="https://rhetoricpaper.org/ ">help with writing papers</a> free printable elementary writing paper
writing reflective paper <a href="https://rhodiumpaper.net/ ">lined writing paper for first grade</a> custom research papers for sale
umi dissertation publishing <a href="https://dissertationwsservicesqgy.c... ">proposal for dissertation</a> sample of dissertation proposal pdf
dissertation in uk <a href="https://dissertationwserviceseds.co... ">rutgers dissertation format</a> dissertation abstracts international section b: the sciences and engineering
editing dissertation <a href="https://dissertationsservicestbs.co... ">writing my dissertation</a> writing dissertation
printable writing paper first grade <a href="https://rhodiumpaper.net/ ">orton-gillingham writing paper</a> thankful writing paper
dissertation def <a href="https://dissertationwserviceseds.co... ">phd dissertation writing services</a> dissertation literature review
essay writing services for cheap <a href="https://essayslurrily.net/ ">critical essay help</a> english essay help
essay writers for hire <a href="https://essayslumber.net/ ">service essay</a> custom writing essay service
i need help writing a narrative essay <a href="https://essayexpo.net/ ">best online essay writers</a> college essay writing company
how to do a thesis statement <a href="https://thesisokusa.com/ ">where are you going where have you been thesis</a> barrett thesis repository
Good site you've got here.. It's hard to find high-quality
writing like yours nowadays. I honestly appreciate
individuals like you! Take care!!
Yes! Finally something about pay for essay.
tadalafil dosage 40 mg <a href="https://tadafilax.com/ ">https://tadafilax.com/</a> tadalafil effect on blood pressure
seroquel cost walmart <a href="https://seroquelquetiapinedik.com/ ">seroquel tablets</a> seroquel for anxiety reviews
omeprazole bone density loss <a href="https://prilosecomeprazolerls.com/ ">https://prilosecomeprazolerls.com/&... prilosec coupons printable easy
prozac and valium <a href="https://prozacfluoxetineatb.com/ ">https://prozacfluoxetineatb.com/<... gabapentin fluoxetine