0

I have a website that calls this "live chat" script in the header:

<script src='http://widget.rlcdn.net/widget/rl_chatwidget.js'></script>

However, on the mobile version of this site, the "Live Chat" widget gets in the way of the site.

Any suggestions on how to bypass a script if visited by a mobile browser?

kaya3
  • 47,440
  • 4
  • 68
  • 97

2 Answers2

0

You'll need some server side logic here to add the script dinamically. You can inspect the request headers and detect the user agent. If it isn't a mobile client, add the script link with server side language, and the opposite if it's.

Oscar
  • 13,594
  • 8
  • 47
  • 75
0
<script type="text/javascript">
     var ismobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));

     if(!ismobile) document.write('<script src="http://source.com/script.js"></script>');
</script>

Source: Hide Javascript file for mobile devices

Community
  • 1
  • 1
z1m.in
  • 1,661
  • 13
  • 19