Reputation: 941
I recently found out over the weekend that iframes are not valid in XHTML strict. What would the correct way to refresh certain content then? A friend said just use divs and have JavaScript refresh them, is this true?
Upvotes: 1
Views: 189
Reputation: 2191
Your friend is right in a sense. You can achieve a similar effect to iframes by using AJAX to load a page into a <div>
container. The problem is that AJAX requests are usually limited within the same domain, so you will not be able to load other websites. You can load other pages from your own domain though.
AJAX is ridiculously easy with jQuery. Check out this function:
<div id="externalcontent">This text will be replaced.</div>
<script type="text/javascript">
$('#externalcontent').load('separate_pages/page2.html');
</script>
This would be kind of pointless as you could just load the content using server-side methods, but it shows how easy loading another page can be with jQuery.
Upvotes: 1
Reputation: 706
Javascript is good. Check out jQuery (http://jquery.com/) for easier DOM manipulation!
Upvotes: 1
Reputation: 1620
Use XHTML Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
http://www.jonasjohn.de/snippets/html4strict/frameset-example.htm
Upvotes: 1