loading content into div tags!

Soldato
Joined
3 Mar 2008
Posts
3,147
Location
Canterbury, Kent
Im designing a website and want to create it to just be on one page with all the text on different pages being loaded into the central div tag on the main page! so the user actually never leaves this first page!!!!

so basically i want to load content (plain text) from one page that i have into a div tag on my home page at the click of one of my hyperlinks!

any help please
 
If you mean something like this, it's just done with Javascript:
Code:
function page1(){
	document.getElementById('index').innerHTML = 'New content for index div';
	document.getElementById('right').innerHTML = 'New content for right div';
}
function page2(){
	document.getElementById('index').innerHTML = 'New content for index div';
	document.getElementById('right').innerHTML = 'New content for right div';
}

You will have the divs of your front page (which obviously can be styled in your CSS):
Code:
<div id="index">Content for index div</div>
<div id="right">Content for right div</div>

Then, call the function on the hyperlink:
Code:
<a href="#" onclick='page1()'>Page 1</a>
<a href="#" onclick='page2()'>Page 2</a>

I've chosen to demonstrate the change of two divs, just incase - if you have one div that you would like to change to 'loading' while the other div is loading images or something. Be sure to remember to link your HTML file to the Javascript file.

being a real noob what would i put where? and yea exactly like that site thats perfectly right
 
trouble is i dont know any php! hehe i do the designing my mate does the hosting and that side!. my limits are html, css and js! any help with this php?

answer tro kemik: cause its the look i want for the site! clean cut and profesional lol
 
I mean no offense here but I certainly wouldn't call that professional. At least it's not something I (or anyone at the firm I work for) would consider using for an entire site.

im only just starting out with web design so no insults lol, i just want a simple small site without moving of the home page! maybe you'd have a lovely solution!
 
Don't get me wrong, I was not trying to insult you. I'm just saying that for a paying client, it's not something most professionals would do. (I'm not saying it's something we would never use - but is definitely not something to base the entire layout around)

What's going to happen if someone has javascript disabled? What if someone is using a screen reader? What if someone is looking at the site on their mobile? Is it still going to display correctly or at least degrade gracefully?
Also, how are the search engines going to like having all the content jumbled on a single page of code?

If you don't want to use a CMS, I don't understand why you can't just create a simple template using php includes? It's incredibly easy to do and for someone with zero php knowledge, a google search followed by a quick bit of reading should give you some results within an hour at most.

In the end, it's your client and your creation so you do what you like. I'm just saying there are better ways of doing it.

lol no offence taken, i understand about the accesability and trouble with search engines, as for mobiles i hadnt thought about lol i just been researching php and am i right in thinking i need to download a package to use it? or can i just write the code straight into notepad?
 
Back
Top Bottom