-1

I bought a responsive website template that I'm trying to edit. I would like to put a search box that I get from another affiliate site, using <script> code, this search box is having a set width and height and it is not responsive. My website looks fine in desktop but not in mobile version. How can I add IF statement to my html file to replace the <script> for search box with another one based on screen size of viewer.

simply I want to replace <script .....></script> with another one if the visitor is browsing from mobile device.

Thanks

Roger Lindsjö
  • 10,912
  • 1
  • 39
  • 49
wa7eed
  • 9
  • You can't just ... delete a script that has already executed – John Dvorak Apr 14 '13 at 14:59
  • not trivial but could setup an interval loop on page load to check for existence of the dynamically generated element and make adjustments once it exists...likely can't replace it or third party script would break – charlietfl Apr 14 '13 at 15:15
  • It would be simpler to alter the script so it behaves properly at different resolutions. – FoolishSeth Apr 14 '13 at 15:17
  • mmm can't we put 2 scripts and say if mobile browser/device (or screen resolution) use script1 if else use script2 – wa7eed Apr 14 '13 at 15:18
  • The problem I can't alter the script it is from different website, however I can make two scripts with different sizes, I only need to change it in my html code if the visitor browsing from mobile. – wa7eed Apr 14 '13 at 15:20
  • See also: http://stackoverflow.com/questions/10508669/tell-html-doc-not-to-load-js-if-mobile-device and http://stackoverflow.com/questions/4875914/loading-js-script-for-only-ios-devices – tcovo Apr 14 '13 at 15:59
  • can you show the link or script that you are trying to add? – TheVillageIdiot Apr 16 '13 at 10:42

1 Answers1

0

You're going to need a way to see whether you're browsing through a website or not. Wurfle (PHP) is a good way to achieve this.

If if were just graphical, you could also alter the styles using the "media" attributes.

Pierre Arlaud
  • 3,644
  • 3
  • 26
  • 38