How can I make a webpart invisible if the page is viewed from a mobile device?


You can solve it using a script on the page that detects if the current browser is coming from a mobile or not. Mobile browsers support the orientation property of the window object. So you can get the ID of the webpart, or the webpart zone, and hide it if it's a mobile browser like the following:

  $("#webpartID").hide();  /* Hide webpart here */

To make it dynamic in case you're deploying through visual studio and you don't know the container ID beforehand, you can get the parent of the webpart through jQuery to retrieve the container.

| improve this answer | |

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.