ShareThis

Thursday, August 9, 2012

jQuery Alternative to using iFrames

You can accomplish the same effect of an iFrame using jQuery's .Load functionality (ajax).

Here is a very simple process to switch over:

Instead of having an iFrame for your content, create a <div>


<div id="content">
Stuff...
</div>

Next, on your navigation pane, simply create onclick functions that call a javascript function that does the following:

<script type="text/javascript">
function articleLinkClick()
{
  $('#content').load('article.html');
}
</script>
This will make an ajax call and load article.html inside your content div. You can do the same with .php documents, and the serverside code will run as normal.

0 comments:

Post a Comment