Javascript - Run my script only if landscape is detectedCreate GUID / UUID in JavaScript?How do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?
How to pass hash as password to ssh server
Why does sound not move through a wall?
A factorization game
Which sphere is fastest?
How do I, as a DM, handle a party that decides to set up an ambush in a dungeon?
Why did the Apollo 13 crew extend the LM landing gear?
How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?
Would a small hole in a Faraday cage drastically reduce its effectiveness at blocking interference?
Has the Hulk always been able to talk?
Notation: What does the tilde below of the expectation mean?
Why do these characters still seem to be the same age after the events of Endgame?
GitLab account hacked and repo wiped
Voltage Balun 1:1
Dihedral group D4 composition with custom labels
Do publishers care if submitted work has already been copyrighted?
Trigonometry substitution issue with sign
Constitutional limitation of criminalizing behavior in US law?
Can I use a Cat5e cable with an RJ45 and Cat6 port?
Install LibreOffice-Writer Only not LibreOffice whole package
Is disk brake effectiveness mitigated by tyres losing traction under strong braking?
What to use instead of cling film to wrap pastry
Correct way of drawing empty, half-filled and fully filled circles?
Can you use "едать" and "игрывать" in the present and future tenses?
Dangerous workplace travelling
Javascript - Run my script only if landscape is detected
Create GUID / UUID in JavaScript?How do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am running a script to show a notification within a menu with scroll, but I do not know how to detect if the device has orientation landscape to validate the script.
The call onClick="VerHayMas();"
works perfectly, but if the user open the menu once, clicking on #boton-menu
and with your device in portrait, after changing the orientation to landscape the script no longer meet the objective.
The script has its logic ONLY if the device is in landscape, which is
when the menu needs to show the notification.
So, is it possible that my script is only valid with (max-width:999px) and (orientation:landscape)
, ignoring the portrait...?
I am a beginner in JS, and I do not know how to do it, really.
Any idea?
Thanks in advance!
HTML & CSS
#mas-menu display:none
<div id="boton-menu" onClick="VerHayMas();">+</div>
Script:
var clicksVerHayMas = 0;
function VerHayMas()
clicksVerHayMas = clicksVerHayMas + 1;
if (clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
, 4000);
;
EDIT:
I have tried with the following script, but it does not work. If the user makes a call to onClick="VerHayMas();"
in portrait mode, the script is no longer running in landscape mode.
What am I doing wrong here?
const matchesMediaQuery = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (matchesMediaQuery)
var clicksVerHayMas = 0;
function VerHayMas()
clicksVerHayMas = clicksVerHayMas +1;
if(clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
,4000);
;
javascript jquery
add a comment |
I am running a script to show a notification within a menu with scroll, but I do not know how to detect if the device has orientation landscape to validate the script.
The call onClick="VerHayMas();"
works perfectly, but if the user open the menu once, clicking on #boton-menu
and with your device in portrait, after changing the orientation to landscape the script no longer meet the objective.
The script has its logic ONLY if the device is in landscape, which is
when the menu needs to show the notification.
So, is it possible that my script is only valid with (max-width:999px) and (orientation:landscape)
, ignoring the portrait...?
I am a beginner in JS, and I do not know how to do it, really.
Any idea?
Thanks in advance!
HTML & CSS
#mas-menu display:none
<div id="boton-menu" onClick="VerHayMas();">+</div>
Script:
var clicksVerHayMas = 0;
function VerHayMas()
clicksVerHayMas = clicksVerHayMas + 1;
if (clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
, 4000);
;
EDIT:
I have tried with the following script, but it does not work. If the user makes a call to onClick="VerHayMas();"
in portrait mode, the script is no longer running in landscape mode.
What am I doing wrong here?
const matchesMediaQuery = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (matchesMediaQuery)
var clicksVerHayMas = 0;
function VerHayMas()
clicksVerHayMas = clicksVerHayMas +1;
if(clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
,4000);
;
javascript jquery
1
You can get the width and height of a window withwindow.innerHeight
andwindow.innerWidth
respectively. How about keep it simple, if height is less than width, the user is in landscape mode.
– Alicia
5 hours ago
add a comment |
I am running a script to show a notification within a menu with scroll, but I do not know how to detect if the device has orientation landscape to validate the script.
The call onClick="VerHayMas();"
works perfectly, but if the user open the menu once, clicking on #boton-menu
and with your device in portrait, after changing the orientation to landscape the script no longer meet the objective.
The script has its logic ONLY if the device is in landscape, which is
when the menu needs to show the notification.
So, is it possible that my script is only valid with (max-width:999px) and (orientation:landscape)
, ignoring the portrait...?
I am a beginner in JS, and I do not know how to do it, really.
Any idea?
Thanks in advance!
HTML & CSS
#mas-menu display:none
<div id="boton-menu" onClick="VerHayMas();">+</div>
Script:
var clicksVerHayMas = 0;
function VerHayMas()
clicksVerHayMas = clicksVerHayMas + 1;
if (clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
, 4000);
;
EDIT:
I have tried with the following script, but it does not work. If the user makes a call to onClick="VerHayMas();"
in portrait mode, the script is no longer running in landscape mode.
What am I doing wrong here?
const matchesMediaQuery = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (matchesMediaQuery)
var clicksVerHayMas = 0;
function VerHayMas()
clicksVerHayMas = clicksVerHayMas +1;
if(clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
,4000);
;
javascript jquery
I am running a script to show a notification within a menu with scroll, but I do not know how to detect if the device has orientation landscape to validate the script.
The call onClick="VerHayMas();"
works perfectly, but if the user open the menu once, clicking on #boton-menu
and with your device in portrait, after changing the orientation to landscape the script no longer meet the objective.
The script has its logic ONLY if the device is in landscape, which is
when the menu needs to show the notification.
So, is it possible that my script is only valid with (max-width:999px) and (orientation:landscape)
, ignoring the portrait...?
I am a beginner in JS, and I do not know how to do it, really.
Any idea?
Thanks in advance!
HTML & CSS
#mas-menu display:none
<div id="boton-menu" onClick="VerHayMas();">+</div>
Script:
var clicksVerHayMas = 0;
function VerHayMas()
clicksVerHayMas = clicksVerHayMas + 1;
if (clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
, 4000);
;
EDIT:
I have tried with the following script, but it does not work. If the user makes a call to onClick="VerHayMas();"
in portrait mode, the script is no longer running in landscape mode.
What am I doing wrong here?
const matchesMediaQuery = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (matchesMediaQuery)
var clicksVerHayMas = 0;
function VerHayMas()
clicksVerHayMas = clicksVerHayMas +1;
if(clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
,4000);
;
javascript jquery
javascript jquery
edited 4 hours ago
Pablo_Web
asked 5 hours ago
Pablo_WebPablo_Web
1218
1218
1
You can get the width and height of a window withwindow.innerHeight
andwindow.innerWidth
respectively. How about keep it simple, if height is less than width, the user is in landscape mode.
– Alicia
5 hours ago
add a comment |
1
You can get the width and height of a window withwindow.innerHeight
andwindow.innerWidth
respectively. How about keep it simple, if height is less than width, the user is in landscape mode.
– Alicia
5 hours ago
1
1
You can get the width and height of a window with
window.innerHeight
and window.innerWidth
respectively. How about keep it simple, if height is less than width, the user is in landscape mode.– Alicia
5 hours ago
You can get the width and height of a window with
window.innerHeight
and window.innerWidth
respectively. How about keep it simple, if height is less than width, the user is in landscape mode.– Alicia
5 hours ago
add a comment |
2 Answers
2
active
oldest
votes
You can solve this using matchMedia
:
const matchesMediaQuery = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (matchesMediaQuery)
// do something
Make sure to note the browser support in the MDN link.
EDIT TO PROVIDE CONTEXT:
Because the user may be moving around their screen, you will want to make this evaluation inside VerHayMas
, each time it is run, to determine if the main body of the script should be executed:
var clicksVerHayMas = 0;
function VerHayMas()
var isLandscapeAndMeetsSizeRequirements = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (isLandscapeAndMeetsSizeRequirements)
clicksVerHayMas = clicksVerHayMas + 1;
if (clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
, 4000);
;
So VerHayMas
will be run on every click, but only if the screen meets the requirements as determined by the media query string will it execute the code inside the if
block.
1
Couldn't you simply run thatmatchMedia
inside ofVeryHayMas
so that it evaluates the screen size and orientation immediately before it needs to act on that information? Of course there orientation may change, so you will need to run it each time you make the check.
– Alexander Nied
4 hours ago
@Pablo_Web - Updated answer with an example showing how this would work.
– Alexander Nied
4 hours ago
Alexander Nied ... Now I understand. I was doing it wrong. I will study your script. It is very clean and tidy. Thank you!. Greetings...
– Pablo_Web
4 hours ago
add a comment |
I'd keep it simple, if screen height is less than width, then the user is in landscape mode. You can grab the height and width from the global window
object.
if (window.innerWidth > window.innerHeight)
// The user is in landscape mode!
userInLanscapeFunc();
Reference: https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight
Maybe it would be better to usescreen.width
/.height
though it depends if they actually care about the shape of the available window area or the screen orientation
– ᆼᆺᆼ
4 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55978407%2fjavascript-run-my-script-only-if-landscape-is-detected%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can solve this using matchMedia
:
const matchesMediaQuery = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (matchesMediaQuery)
// do something
Make sure to note the browser support in the MDN link.
EDIT TO PROVIDE CONTEXT:
Because the user may be moving around their screen, you will want to make this evaluation inside VerHayMas
, each time it is run, to determine if the main body of the script should be executed:
var clicksVerHayMas = 0;
function VerHayMas()
var isLandscapeAndMeetsSizeRequirements = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (isLandscapeAndMeetsSizeRequirements)
clicksVerHayMas = clicksVerHayMas + 1;
if (clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
, 4000);
;
So VerHayMas
will be run on every click, but only if the screen meets the requirements as determined by the media query string will it execute the code inside the if
block.
1
Couldn't you simply run thatmatchMedia
inside ofVeryHayMas
so that it evaluates the screen size and orientation immediately before it needs to act on that information? Of course there orientation may change, so you will need to run it each time you make the check.
– Alexander Nied
4 hours ago
@Pablo_Web - Updated answer with an example showing how this would work.
– Alexander Nied
4 hours ago
Alexander Nied ... Now I understand. I was doing it wrong. I will study your script. It is very clean and tidy. Thank you!. Greetings...
– Pablo_Web
4 hours ago
add a comment |
You can solve this using matchMedia
:
const matchesMediaQuery = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (matchesMediaQuery)
// do something
Make sure to note the browser support in the MDN link.
EDIT TO PROVIDE CONTEXT:
Because the user may be moving around their screen, you will want to make this evaluation inside VerHayMas
, each time it is run, to determine if the main body of the script should be executed:
var clicksVerHayMas = 0;
function VerHayMas()
var isLandscapeAndMeetsSizeRequirements = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (isLandscapeAndMeetsSizeRequirements)
clicksVerHayMas = clicksVerHayMas + 1;
if (clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
, 4000);
;
So VerHayMas
will be run on every click, but only if the screen meets the requirements as determined by the media query string will it execute the code inside the if
block.
1
Couldn't you simply run thatmatchMedia
inside ofVeryHayMas
so that it evaluates the screen size and orientation immediately before it needs to act on that information? Of course there orientation may change, so you will need to run it each time you make the check.
– Alexander Nied
4 hours ago
@Pablo_Web - Updated answer with an example showing how this would work.
– Alexander Nied
4 hours ago
Alexander Nied ... Now I understand. I was doing it wrong. I will study your script. It is very clean and tidy. Thank you!. Greetings...
– Pablo_Web
4 hours ago
add a comment |
You can solve this using matchMedia
:
const matchesMediaQuery = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (matchesMediaQuery)
// do something
Make sure to note the browser support in the MDN link.
EDIT TO PROVIDE CONTEXT:
Because the user may be moving around their screen, you will want to make this evaluation inside VerHayMas
, each time it is run, to determine if the main body of the script should be executed:
var clicksVerHayMas = 0;
function VerHayMas()
var isLandscapeAndMeetsSizeRequirements = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (isLandscapeAndMeetsSizeRequirements)
clicksVerHayMas = clicksVerHayMas + 1;
if (clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
, 4000);
;
So VerHayMas
will be run on every click, but only if the screen meets the requirements as determined by the media query string will it execute the code inside the if
block.
You can solve this using matchMedia
:
const matchesMediaQuery = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (matchesMediaQuery)
// do something
Make sure to note the browser support in the MDN link.
EDIT TO PROVIDE CONTEXT:
Because the user may be moving around their screen, you will want to make this evaluation inside VerHayMas
, each time it is run, to determine if the main body of the script should be executed:
var clicksVerHayMas = 0;
function VerHayMas()
var isLandscapeAndMeetsSizeRequirements = window.matchMedia('(max-width:999px) and (orientation:landscape)').matches;
if (isLandscapeAndMeetsSizeRequirements)
clicksVerHayMas = clicksVerHayMas + 1;
if (clicksVerHayMas == 1)
document.getElementById('mas-menu').style.display = 'block';
window.setTimeout(function()
$('#mas-menu').fadeOut('slow');
, 4000);
;
So VerHayMas
will be run on every click, but only if the screen meets the requirements as determined by the media query string will it execute the code inside the if
block.
edited 4 hours ago
answered 5 hours ago
Alexander NiedAlexander Nied
4,38211130
4,38211130
1
Couldn't you simply run thatmatchMedia
inside ofVeryHayMas
so that it evaluates the screen size and orientation immediately before it needs to act on that information? Of course there orientation may change, so you will need to run it each time you make the check.
– Alexander Nied
4 hours ago
@Pablo_Web - Updated answer with an example showing how this would work.
– Alexander Nied
4 hours ago
Alexander Nied ... Now I understand. I was doing it wrong. I will study your script. It is very clean and tidy. Thank you!. Greetings...
– Pablo_Web
4 hours ago
add a comment |
1
Couldn't you simply run thatmatchMedia
inside ofVeryHayMas
so that it evaluates the screen size and orientation immediately before it needs to act on that information? Of course there orientation may change, so you will need to run it each time you make the check.
– Alexander Nied
4 hours ago
@Pablo_Web - Updated answer with an example showing how this would work.
– Alexander Nied
4 hours ago
Alexander Nied ... Now I understand. I was doing it wrong. I will study your script. It is very clean and tidy. Thank you!. Greetings...
– Pablo_Web
4 hours ago
1
1
Couldn't you simply run that
matchMedia
inside of VeryHayMas
so that it evaluates the screen size and orientation immediately before it needs to act on that information? Of course there orientation may change, so you will need to run it each time you make the check.– Alexander Nied
4 hours ago
Couldn't you simply run that
matchMedia
inside of VeryHayMas
so that it evaluates the screen size and orientation immediately before it needs to act on that information? Of course there orientation may change, so you will need to run it each time you make the check.– Alexander Nied
4 hours ago
@Pablo_Web - Updated answer with an example showing how this would work.
– Alexander Nied
4 hours ago
@Pablo_Web - Updated answer with an example showing how this would work.
– Alexander Nied
4 hours ago
Alexander Nied ... Now I understand. I was doing it wrong. I will study your script. It is very clean and tidy. Thank you!. Greetings...
– Pablo_Web
4 hours ago
Alexander Nied ... Now I understand. I was doing it wrong. I will study your script. It is very clean and tidy. Thank you!. Greetings...
– Pablo_Web
4 hours ago
add a comment |
I'd keep it simple, if screen height is less than width, then the user is in landscape mode. You can grab the height and width from the global window
object.
if (window.innerWidth > window.innerHeight)
// The user is in landscape mode!
userInLanscapeFunc();
Reference: https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight
Maybe it would be better to usescreen.width
/.height
though it depends if they actually care about the shape of the available window area or the screen orientation
– ᆼᆺᆼ
4 hours ago
add a comment |
I'd keep it simple, if screen height is less than width, then the user is in landscape mode. You can grab the height and width from the global window
object.
if (window.innerWidth > window.innerHeight)
// The user is in landscape mode!
userInLanscapeFunc();
Reference: https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight
Maybe it would be better to usescreen.width
/.height
though it depends if they actually care about the shape of the available window area or the screen orientation
– ᆼᆺᆼ
4 hours ago
add a comment |
I'd keep it simple, if screen height is less than width, then the user is in landscape mode. You can grab the height and width from the global window
object.
if (window.innerWidth > window.innerHeight)
// The user is in landscape mode!
userInLanscapeFunc();
Reference: https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight
I'd keep it simple, if screen height is less than width, then the user is in landscape mode. You can grab the height and width from the global window
object.
if (window.innerWidth > window.innerHeight)
// The user is in landscape mode!
userInLanscapeFunc();
Reference: https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight
answered 5 hours ago
AliciaAlicia
1,76422137
1,76422137
Maybe it would be better to usescreen.width
/.height
though it depends if they actually care about the shape of the available window area or the screen orientation
– ᆼᆺᆼ
4 hours ago
add a comment |
Maybe it would be better to usescreen.width
/.height
though it depends if they actually care about the shape of the available window area or the screen orientation
– ᆼᆺᆼ
4 hours ago
Maybe it would be better to use
screen.width
/.height
though it depends if they actually care about the shape of the available window area or the screen orientation– ᆼᆺᆼ
4 hours ago
Maybe it would be better to use
screen.width
/.height
though it depends if they actually care about the shape of the available window area or the screen orientation– ᆼᆺᆼ
4 hours ago
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55978407%2fjavascript-run-my-script-only-if-landscape-is-detected%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You can get the width and height of a window with
window.innerHeight
andwindow.innerWidth
respectively. How about keep it simple, if height is less than width, the user is in landscape mode.– Alicia
5 hours ago