Thank you crispy68, for handing me "The Golden Key", which was the two words "media queries".
I had not heard of them, but spent the next 90 minutes searching Google for them.
"Media queries" led me to "@media" and a list of values it can provide.
I saw "height" was one of those values, and I thought to myself,
"Desktops are wider than tall, and cell phones are taller than wide. Eurika, I have it! Compare high and wide!"
But soon, that search led to the "@meda" value named "orientation", which has high and wide already compared.
So, two hours after reading your reply, I have code that works:
Code: Select all
<script type="text/javascript">
window.addEventListener('resize', function() {
var orientation = (screen.orientation || {}).type || screen.mozOrientation || screen.msOrientation;
if (orientation.includes("portrait"))
{ alert("IS A CELL PHONE"); }
else
{ alert("IS A DESK TOP"); }
});
</script>
I tip my cell phone 90 degrees, and it tells me correctly which way I'm looking at it.
Now I just need to swap the "alert()s" for page redirections, like:
Code: Select all
window.location.href = "http://www.webviews.us/dreamlight.html";
(Also, I must set it correctly when the page first loads with version of:
But that's easy.
Again, thank you for providing "The Golden Key". It fit the lock perfectly.