When it comes to a chat application, my preference is always for using a div over an iframe.
One key advantage of using a div is the ability to handle events that cannot be handled within an iframe. Try experimenting with events like click
and mouseover
inside an iframe - you'll find that they are unresponsive.
$('div').click(function () {
alert('Div was clicked!');
}
Unlike iframes, a div allows access to events on its child elements, providing more flexibility for handling and coding as needed. Iframes require event handling within the iframe itself, making it more cumbersome.
$('iframe').click(function () {
// code..this will execute when click is on iframe, not for a child
}
Furthermore, manipulating elements within a div is simpler as compared to iframes. A chat app benefits greatly from being able to manage all element events effectively.
<div>
Some text
</div>
In a div, updating content through ajax requests and scrolling using jQuery API can be seamlessly implemented, regardless of page size.
$('div').load('chat_page.php'); // load a page in the div
On the other hand, iframes are best suited for sharing functionality without exposing code, such as embedding a chat application in a third-party site.
Regarding scrolling techniques, utilizing the scrollTo function on a div can achieve the desired effect.
$('div').scrollTo(10); // scroll 10px down..
As for browser support, both jQuery and HTML have excellent cross-browser compatibility.
http://jquery.com/browser-support/ For more information on browser support.