ฉันจะไม่พูดเรื่องไร้สาระมากฉันจะโพสต์รหัสให้คุณ
รหัสเฉพาะมีดังนี้:
<! doctype html> <html lang = "en"> <head> <meta charset = "utf-8"> <title> เอกสาร </title> </head> <script src = "http://libs.baidu.com/jquery/1.9.0/jquery.js" ScreenorientationEvent () {ถ้า (ทิศทาง (ทิศทาง == 0) {document.getElementById ("เปลี่ยน"). value = "แนวตั้ง"; $ ("body"). css ({'transform': 'หมุน (90deg)', '-webkit-transform': 'rotate (90deg)', '-moz-transform' se {document.getElementById ("เปลี่ยน"). value = "แนวนอน"; $ ("body"). css ({'transform': 'หมุน (0deg)', '-webkit-transform': 'หมุน (0deg)', '-moz-transform' InnerWidThtmp = window.innerWidth; // hori และวิธีการฟังหน้าจอแนวตั้งวิธีการฟังฟังก์ชั่น screenorientationListener () {ลอง {var iw = window.innerWidth; // การประมวลผลทิศทางของหน้าจอถ้า (iw! = innerWidthtmp) {ถ้า 0;} // การแปลงหน้าจอเหตุการณ์การแปลง ScreenorientationEvent (); InnerWidThtmp = iw;}} catch (e) {Alert (e);}; // ช่วงเวลาที่กำหนดตรวจสอบว่าหน้าจอถูกหมุนหรือไม่, เริ่มต้น 500ms settimeout ("screenorientationListener ()") </scriptation) id = "เปลี่ยน" type = "text" value = ""/> </body> </html>รหัส JS ข้างต้นเป็นรหัสหลักสำหรับการใช้หน้าจอแนวนอนบนมือถือ รหัสนั้นง่ายและเข้าใจง่าย ฉันไม่ได้แนบความคิดเห็นมากเกินไปกับคุณ หากคุณไม่เข้าใจอะไรโปรดฝากข้อความถึงฉัน บรรณาธิการจะตอบกลับคุณทันเวลา ขอบคุณมากสำหรับการสนับสนุนเว็บไซต์ Wulin Network!