最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How can I Force desktop view on a mobile device from my HTML or JavaScript code - Stack Overflow

programmeradmin3浏览0评论

I'm updating site and the mobile view isn't looking that presentable. I tried rewriting the code, but it's still frustrating, as I wasn't the person who built the front-end

Is there any code either in the { header } or a JavaScript function that can achieve this?

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

I'm updating site and the mobile view isn't looking that presentable. I tried rewriting the code, but it's still frustrating, as I wasn't the person who built the front-end

Is there any code either in the { header } or a JavaScript function that can achieve this?

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

Share Improve this question edited May 13, 2020 at 19:41 Ogoh.cyril asked Oct 12, 2019 at 19:39 Ogoh.cyrilOgoh.cyril 4591 gold badge7 silver badges14 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

You can change the meta link to display a desktop version:

<meta name="viewport" content="width=1024">

Instead of the responsive version which is:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

I remended a few solutions for you

if you want to identify the device use JavaScript

/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)

OR

'ontouchstart' in document.documentElement)

But you can use css with screen width

@media only screen and (max-width: 560px) { .exampleclass {} }

Or create a custom file for the mobile version and call it in the header

<link rel="stylesheet" media="screen and (max-width: 560px)" href="mobile.css" />

Here are a couple of things you can try -

  1. In some cases, it will work. The issue with this is, it widens the mobile browser view, not exactly the desktop view.

<meta name="viewport" content="width=1024">

  1. Update the scale in meta tag. It worked for my website properly.

<meta name="viewport" content="width=device-width, initial-scale=0.1">

(See, it's 0.1 instead of 1.0)

发布评论

评论列表(0)

  1. 暂无评论