-2

I have a CMS homepage which has many widgets(Drupal block). some widgets connects to external website via internet. some widgets are locally displayed via Intranet.

Intranet Website is accessible to only TPN User .Some User have Internet Access enabled via proxy server to them home page loads all the widgets very fast

All the Internet(External) Widgets uses iframes to load pages.

Example Drupal Widgets:

1)NHL report

2)Snow report

3)Cricket online

4)Southwest Train Status

To the users who don't have internet connection browser show continues loading to a very long time until all the Internet widgets failed to load. How do I disable these widgets using javascript or PHP ?

I want to know if user has an internet connection or not. if no internet connection then disable those widgets which tries to connect via internet. This may avoid browser being busy loading continuously.

Problem is the homepage loads slow to the user who dont have internet access . And I want a solution to disable the Internet Widgets(Iframe) from being loaded . Is it possible to do?

B L Praveen
  • 1,310
  • 2
  • 18
  • 39
  • Is it a duplicate question. Sorry I know it is duplicate. But my question was how to avoid these widgets from loading – B L Praveen May 05 '15 at 12:26
  • @charlietfl I did not understand. – B L Praveen May 05 '15 at 12:27
  • Widgets are drupal homebox blocks – B L Praveen May 05 '15 at 12:27
  • do periodic ajax checks – charlietfl May 05 '15 at 12:32
  • I want check if users has an internet connection. I'm not worried if connections goes off – B L Praveen May 05 '15 at 12:36
  • This is complex. You might want to search for polling using ajax/javascript. [More about polling](https://en.wikipedia.org/wiki/Polling_(computer_science)) – jazZRo May 05 '15 at 12:38
  • So what environment is this in? if it's a web page...can't load page anyway. If it's mobile app use device to check – charlietfl May 05 '15 at 12:43
  • What I initially thought was to mark all the block with a class name (re-internet) which connect to external network. Check internet connection exists in jquery. if no internet connection then remove those widgets to the users – B L Praveen May 05 '15 at 12:45
  • The above method did not work. page still shows busy loading to some time until ajax finds that there is not internet connection. – B L Praveen May 05 '15 at 12:46
  • @charlietfl it is webpage(CMS) not mobile application – B L Praveen May 05 '15 at 13:01
  • So how will page load if there is no connection? Something is missing in your environment description or having an internet connection is not your problem – charlietfl May 05 '15 at 13:05
  • Page will load via local Intranet connection TPN – B L Praveen May 08 '15 at 05:25
  • @charlietfl WHAT IS WRONG WITH THE QUESTION NOW? WHY IT IS DOWN VOTED. REALLY UPSET. Is the question unclear still or it is a stupid question – B L Praveen May 09 '15 at 05:26
  • then why wasn't `intranet` explained when asked about environment? – charlietfl May 09 '15 at 14:22
  • @charlietfl I did not understand.I wanted feeback if anybody confronts the same problem and found a solution. As I am not able to make it clear my question on first go. I dont understand why questions is still unclear and closed – B L Praveen May 11 '15 at 04:29
  • Suggest you just start another one...written properly as per the links in the help center box. With proper explanation and problem statement and all pertinent network issues included – charlietfl May 11 '15 at 04:31
  • Then why it was asked to edit the question and later closed. I dont want to lose more points by repeating this question. tha's it. I understood not jump here to my big questions which I dont have any plan or solution. – B L Praveen May 11 '15 at 05:04

1 Answers1

2

What you CAN do is try to load an image from the internet, if loading fails, you can conclude you don't have an internet connection. Make sure it's located on an external server which is yours, so you're almost always certain it's still online available.

<img src="http://website.org/image.png" alt="image" onerror="methodWhenNoInternetConnection()" />

This option works if you only want to use JavaScript. But there are "smarter" ways to do this, with PHP for example: Determine in php script if connected to internet?

Another option is calling a PHP script with AJAX, which checks your internet connection and returns a value.

Community
  • 1
  • 1
Erik van de Ven
  • 3,978
  • 4
  • 27
  • 68
  • All the external block uses iframes to show widgets(NHL report, Snow report, Cricket online, Southwest Train Status). Is it possible to load iframe via ajax – B L Praveen May 05 '15 at 12:54
  • @erik-vav-de-ven Thanks you very much. It was indeed helpfull – B L Praveen May 05 '15 at 13:00
  • I would look further how to load iframe via ajax – B L Praveen May 05 '15 at 13:03
  • Alright great ;) But as far as I know you cannot load an iframe with Ajax... You can load it's url to check the internet connection, but you load an iframe with javascript by setting the ```src``` attribute with javascript. – Erik van de Ven May 05 '15 at 13:14