How to detect Android in JavaScript?

Is it possible to detect when a request is sent by the browser and when an answer is posted?(with javascript)?

  • I am using jQuery to pop up a dialog box that might contain different things from iframes to image to ajax...I need a way to detect when a request is sent and when the loading is completed ( the answer to the request) in order to create a "loading..." message that would work for any instance. with Ajax it is easy ( ajax status), so it is with an img ( onload action) but iframes I have no idea how to do it...besides it would be nice to have a universal approach for all instead of a specific one for each case. I figured since the browser itself knows when a request is sent ( hence the hour glass and the loading bar) there should be a way to read that...ideally in Javascript if possible...thank you for your help

  • Answer:

    Not sure why frame should be a problem. The tags that support onload events are: body, frame (and iframe and frameset), img, link, and script You can use embedded script tags to simulate onload for other elements that can contain script blocks. A simple example of this is: <head> <script type="text/javascript"> // simulate firing onload event for elements // that don't support it function publishEvent(evt, publisher) { // for IE vs. non-IE browsers evt = window.event?window.event:evt; // get script block's parent var el = publisher.parentNode; // do whatever - could be to notify // registered subscribers of events of // given types fired by elements of // given ids alert(el.id + ':' + evt.type); } </script> </head> <body> <div id="div0"> <!-- include.js doesn't need to do anything, but must exist in order for onload event to fire --> <script onload="publishEvent( event, this )" src="include.js"> </script> </div> </body> </html>

Salmane S at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.