1

I have the following problem inside our sharepoint online team site collection:-

  1. i have created a new modern site page.
  2. inside the modern site page, i added many Embed web parts which contains iframes referencing other sharepoint lists/libraries.
  3. we have the mobile view site feature enabled.

now when i access the modern page from my mobile phone, the modern page will be rendered correctly, but for the Embed web parts which contain iframes nothing will be displayed (empty white area). now if i click on "switch to pc view" the iframes will get displayed well inside my mobile screen. so my question is; if there is a way to prevent a modern site age from being rendered in mobile view? i know that i can disable the "mobile view" site feature, but doing so will affect the whole site, while what i am looking for is to disable the mobile view rendering for a single modern site page only.. so is this possible?

1

I think it's impossible to disable mobile view just for one page. But you can disable it for your SharePoint website: Try disabling "Locate Mobile Browser View" feature in Site Settings.

  • thansk for your reply. i already know that i can disable the site feature , but this will affect all the site pages.. while i want to disable the mobile view for a single modern page only. – john Gu Jun 6 '18 at 15:34
1

The easiest solution I can come up with that does not include fondeling with 3rd party software or snooping in the web.config file would be to insert either a usercontrol or some javascript on the page which changes the /?mobile=1 to /?mobile=0.

  • the problem is that inside sharepoint modern pages we can not add javascript code.. now i can add the JavaScript code inside a classic page, and reference the classic page inside my modern page using iframes, but in this case the javascript will change the url for the source classic page and not for the modern page !!! – john Gu Jun 11 '18 at 11:15
  • 1
    You can add Script Editor in Modern pages. There is a Modern Script Editor available in Github. You can use that. github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/…. – Naveen Prasath Jun 11 '18 at 11:18
  • ok looks promising ,, not sure why this is not part of the available modern web parts.. but one question i have regarding deploying this,, can i deploy this as sharepoint hosted app ? as currently i do not have any azure ot external server configured to provider hosted apps? – john Gu Jun 11 '18 at 11:23
  • 1
    Yes, you can create a CDN in SharePoint. You can make any Library to CDN where you can host your publish files. Then app in App catalog site. Use this link to create CDN library. c-sharpcorner.com/blogs/… – Naveen Prasath Jun 11 '18 at 11:26
  • 1
    By Default SPF'x Add-Ins support only CDN libraries. That can be either in Azure or a SharePoint library, or any other CDN you have. SP libraries will not be supported. In Customer Tenant you have to create a new CDN specific for them. – Naveen Prasath Jun 11 '18 at 11:45
0

If you are using SharePoint 2013, try setting up device channels. Device channels enable you to provide a different user experience based upon the device or even browser the user is accessing your site from.

  • 1
    "modern site page" implies SharePoint Online or SharePoint 2016. – Mike Smith - MCT - MVP Jun 6 '18 at 18:18
0
  1. Create an SPFX webpart
  2. Write some code to identify if it's a mobile Eg:

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { // some code.. }

  1. If its a mobile then clear all the webparts by using

this.domElement.innerHTML = "";

Hope this helps.

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.