Home     |      Learn AJAX     |      Forum     |      Register     |      Submit Resource     |      Submit Article      |      Contact Us

Home AJAX-Design
 

Cross-Domain iFrame without Polling

 

The process of implementing cross-domain communication in an Ajax based application can be eased with iFrame. Actually it is not that easy since implementing iFrame for this type of communication, it will still take a few processes. iFrame for cross-domain communication will enable you to detect changes of data easier from other sources and this data be easily streamed in the online application.


The process of communicating across browsers through iFrame requires polling the targeted site. This is practically "monitoring" the source so that the application will have the right reaction. The source is checked through event handlers which send the messages through iFrame.


However, the technique in using polling to implement cross-domain communication can easily put a load in the application. In this technique, iFrame is disposable. This means, the function is deleted as soon as its role in monitoring the changes in the application. So it will take another step in deleting iFrame. Aside from this extra step, the response in polling is only optimized in good internet connection.


Those who have a relatively weak internet connection will not experience the optimized interaction. Polling and iFrame may be able to implement cross domain communication but might never be able to work when they are not implemented in ideal conditions.


There is, in fact, a technique on how to deal with the challenges posed by iFrame and polling. To understand the solution faster, we will deal with the challenges one at a time.


The iFrame Challenge - the problem with iFrame in cross domain communication is basically on its proxy and temporary features. It is only there when needed but deleted when they are not used. But, since you are developing an application that will constantly connect to another source, it is a better option for developers to permanently place an iFrame in the application. With a permanent iFrame, developers will have a constant function to stream information that will never require any deletion.


Polling - polling takes up a lot of functions. Onload, message extraction and communication to iFrame is required before the information is passed to the client side. This steps could take too much time in implementation. Instead of polling, developers can use a "messaging" system in the application. Using two iFrames, developers can use the first iFrame for constant communication with the source while the other will take care of loading the data in the client side.


What will happen is basically a small tweak in cross domain communication. The process of transforming the polling function into pure messaging is a little bit challenging since an additional iFrame will be implemented. The number of steps is almost the same which means it might use the same resources.


But the main difference of iFrame without polling is the efficient messaging system. This technique uses its resources to effectively stream data from one source to another instead of using the resources to dispose proxy iFrame.


Think of JavaScript applications in IE wherein the clicking sound is heard when you the online application tries to extract data from another source. This clicking sound will be removed and the page would load faster.



Read Next: Low, High and Mid-Level APIs



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links