HTML5 REM JS Conversion method

Source: Internet
Author: User

In the low version of the Android phone browser, if the page is executed quickly, the calculation width will appear incorrectly, the solution is to be executed in the OnLoad method, but this solution in some high-version browser will appear in the page flashing, so use to determine the browser version of the way to solve, That is, the version of the browser using the Document.ready method of execution, other high-version phones do not need to use, of course, to determine the iOS phone, iOS phones do not need to determine

/*rem unit conversion Method Iphone6 Fit */

functionResizeroot () {varDPR = 1, uagent =window.navigator.userAgent;//determine your iOS systemvarIsios = Uagent.match (/iphone/i);//Calculate app WidthvarWwidth = (screen.width > 0)? (window.innerwidth >= Screen.width | | window.innerwidth = 0)?screen.width:window.innerWidth:window.innerWidth, WDPR, wfsize;if(window.devicepixelratio) {WDPR=Window.devicepixelratio;} Else {//identify the iOS resolution methodWDPR = Isios? Wwidth > 818? 3:wwidth > 480? 2:1: 1; }//calculate iOS system widthif(isios) Wwidth =screen.width;wfsize= wwidth > 1080? 144:wwidth/7.5; Window.screenwidth_=Wwidth;//assign value to HTML fontsize valuedocument.getElementsByTagName (' HTML ') [0].DATASET.DPR =WDPR; document.getElementsByTagName (' HTML ') [0].style.fontsize = wfsize + ' px ';}//determine the low version of Android phone browser to execute with the Ready methodfunctionappsion () {uagent=window.navigator.userAgent;varIsios = Uagent.match (/iphone/i);if(Navigator.appVersion.substring (navigator.appversion.length-6) <537 &&!Isios) {Document.ready=function() {resizeroot ();} }Else{resizeroot ();}} Appsion ();//rem Configuration method Execution

HTML5 REM JS Conversion method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.