Open content into a DIV

hi everyone.

I have a website, with the main part split in half. the main content is in a div called “mainarea”. this div is then divided into 2 sections. the section in the left is called “content” and the div on the right is called “image”

when i click a link, i want the content to load into the div “mainarea”, thus replacing the content of the other 2 divd (“content” and “image”). how do I load a link into a div, without making the page reload, but also keeping the headers and footers.

thanks.

james

You’d need some sort of script to do that.

It’s not a good idea if it is your intention to imitate frames like that and you would be better off loading new pages if you are talking about lots of content otherwise you end up with a one page site.

If it’s just swapping a small panel of text each time then you can do that with javascript and is a question for the javascript forum (I can move the thread there if you want). If you want to load external content then you’re probably looking at ajax as well.

Here’s a simple example of just switching panels on and off.

If you were thinking of building your whole site like that then it’s not a good idea and you should just load a new page each time as per normal and keep things simple and straight forward.

Paul always gets there before me :wink:
But yes, I do this on various websites, click a link, show different content, and this is best (IMO of course) using jQuery. Despite my intial reluctance to use it, it’s a fantastic amazing (I couldn’t decide which word to use so I used both!) thing to implement!

The logic is simple in jQuery, if link 1 is clicked show content 1, if link 2 is clicked, show content 2 hide all other content.

But agreeing with Paul, you should never build a full site like this, because as it grows it’ll actually end up with 104 different content in the middle, then you might want to change other content as well, then what about if you want to add a form, then we have another issue to work with there, it’ll be a mess.

Let’s learn some jQuery