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

javascript - Is it possible to remove meta viewport with a script? - Stack Overflow

programmeradmin0浏览0评论

I don't have access to the HTML file to get to it from the server side, however I can add additional HTML to the site. MY question is I have a non responsive site listed below, that now because of the new viewport code, I have to ZOOM IN once the site loads, to see the entire site.

WEBSITE

I was trying this, but to no avail.

<script type="text/javascript">
   $('head').remove('<meta name="viewport" content="initial-scale=1.0, width=device-width" />');
   $("head").append('<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />');
</script> 

A perfect situation would be to block or remove the viewport, and have the site load as a non responsive website as it was before.

Thanks!

I don't have access to the HTML file to get to it from the server side, however I can add additional HTML to the site. MY question is I have a non responsive site listed below, that now because of the new viewport code, I have to ZOOM IN once the site loads, to see the entire site.

WEBSITE http://www56.myfantasyleague./2017/home/51277

I was trying this, but to no avail.

<script type="text/javascript">
   $('head').remove('<meta name="viewport" content="initial-scale=1.0, width=device-width" />');
   $("head").append('<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />');
</script> 

A perfect situation would be to block or remove the viewport, and have the site load as a non responsive website as it was before.

Thanks!

Share Improve this question asked Feb 18, 2017 at 0:45 DA-G-GURUDA-G-GURU 1411 gold badge3 silver badges12 bronze badges 1
  • Did you find an answer? – shinil Commented May 11, 2018 at 12:35
Add a ment  | 

2 Answers 2

Reset to default 4

Or you can just try this (Don't need jQuery):

document.getElementsByTagName('meta')['viewport'].content='initial-scale=1.0, user-scalable=no';

The argument to .remove() must be a selector, not an HTML string.

$("head meta[name=viewport]:contains(initial-scale=1.0, width=device-width)").remove();
发布评论

评论列表(0)

  1. 暂无评论