1

I know you can't put if conditions in HTML but then how do I do this.

I need to put this line in my HTML if I have internet connection. If its not possible to check if I have internet connection, then I could put a configurable value in my web.config and check that instead but I don't even know how to do that in HTML.

<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
user2837961
  • 1,505
  • 3
  • 27
  • 67
  • anyways the js file and html will be on server so if it has to work in the clent it has to reach on the machine,without iternet how does that happen or are you making a client side app??? – Arun Killu Feb 18 '14 at 09:24

1 Answers1

2

you can do it by javascript

if (navigator.onLine) {
    // you are online...
}

applied to your case will be:

<script type="text/javascript">
if(navigator.onLine)
  document.write('<scri'+'pt src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></'+'script>');
</script>

that's not the best solution, but will fix your issue

ponciste
  • 2,231
  • 14
  • 16