简体   繁体   中英

Setting mobile user agent for iframe on desktop

I am attempting to use an iframe to preview the mobile version for a site that will be displayed on the desktop site. However the site that I am attempting to display does not use the screen size to activate the mobile version but rather a user agent. Will I be able to somehow make the iframe request the site based of a mobile user agent such as 'Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'?

Your question is marked with both Javascript and PHP tags, two quite different languages, one client-side, the other server-side, respectively. Changing the UserAgent string cannot be done with Javascript. It could be done with a HTTP header set by PHP running on a proxy server between your browser and the site that will load in the iFrame.

On the other hand, if you use node.js server-side, you may be able to set the userAgent header with Javascript (a related OS Q&A may help).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM