Menu icon Foundation
can I load a script for small only?

Hi there,
According to my foundation.js I am on version 5.0.3

I have a snippet of inline javascript from a 3rd-party vendor that uses document.write in it. They are unwilling to provide an alternative script.

The problem is, the script is breaking some desktop browsers with security extensions, such as Chrome.

I need this script to run for mobile (small) but don't need it for desktop. Is there a way for me to load it for small only, without medium and large coming across it and potentially breaking? I tried data-interchange and that really seemed to break things. Visibility classes do not seem like they'd hide the backend script from desktops

Thank you in advance.

conditionalsmall onlyscripts

Hi there,
According to my foundation.js I am on version 5.0.3

I have a snippet of inline javascript from a 3rd-party vendor that uses document.write in it. They are unwilling to provide an alternative script.

The problem is, the script is breaking some desktop browsers with security extensions, such as Chrome.

I need this script to run for mobile (small) but don't need it for desktop. Is there a way for me to load it for small only, without medium and large coming across it and potentially breaking? I tried data-interchange and that really seemed to break things. Visibility classes do not seem like they'd hide the backend script from desktops

Thank you in advance.

Jeanie Chung over 4 years ago

Hey Reese-

Could you post the code snippet here?

We could wrap it in a conditional "if" statement so that the function itself won't run unless the browser is small-sized.

reese over 4 years ago

thank you Jeanie.

Here is the code. It gets inserted directly inline into the html.

thanks again,
reese

<script language="Javascript">document.write("<a href='tel:");DisplayPhoneText("NNNNNNNNNN");document.write("'>");DisplayPhoneText("NNN.NNN.NNNN");document.write("</a>");</script><noscript>888.888.8888</noscript>

reese over 4 years ago

Hi, Jeanie,
I hope it's not improper form for me to give this a gentle bump.

Thank you!
Reese