SoFunction
Updated on 2025-04-03

JavaScript implements a method that calls different style sheets according to the direction of the iPhone screen

This article describes the JavaScript implementation method of calling different style sheets according to the direction of the iPhone screen. Share it for your reference. The details are as follows:

When the iPhone screen rotates, this JS code can dynamically call different styles to adapt to screen transformation

<script type="text/javascript"> 
function orient() 
{
 switch(){ 
  case 0: ("orient_css").href = "css/iphone_portrait.css"; 
  break; 
  case -90: ("orient_css").href = "css/iphone_landscape.css"; 
  break; 
  case 90: ("orient_css").href = "css/iphone_landscape.css"; 
  break; 
}
 = orient();
</script>

I hope this article will be helpful to everyone's JavaScript programming.