2

I don't want to edit any master pages for obvious reasons given that I am on SharePoint Online. But I am trying to achieve responsiveness on my sites. For this, I would really like to use the viewport meta tag.

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

How could I inject that? I've seen some javascript to inject a meta tag, but my fear is this would occur "too late" and even if it works in some of my tests... I may not know when it isn't working in production (or, I could write some more JS to check this, but I wouldn't want faulty code in production anyway).

1
  • god i am so glad i dont have to work with sharepoint anymore. this Q was from an old job I had years ago! SO just reminded me with a "Notable Question" achievement lol Sep 2, 2021 at 22:30

2 Answers 2

5

Use the built in Search Engine optimization settings (Settings > Site Collection Administration > Search Engine Optimization). These options allow for added SEO tags but can be "hijacked" for any metadata tag ;-)

More info here

1
  • 1
    Oh that's clever. Thank you. I also like the implications this have when doing remote provisioning. ...which is still an area of confusion for me so if you have a really great guide for this, please let me know! Lol Mar 6, 2016 at 16:08
0

This solution is working very well for me. I was unaware some meta tags can still be appended after the head is parsed with the desired effect.

https://stackoverflow.com/questions/3588628/can-i-change-the-viewport-meta-tag-in-mobile-safari-on-the-fly

var metaTag=document.createElement('meta');
metaTag.name = "viewport"
metaTag.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
document.getElementsByTagName('head')[0].appendChild(metaTag);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.