Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Is it better to use multiple html pages and link them together with href or just change content on the same page using JavaScript? I am thinking of how to layout a page and I don't have a lot of content. It would probably be about three of for pages if I just used all html. If I toggled and swapped bits of html around using JavaScript, I could probably fit it all on one page, and it would be a bit "cooler", in that it's more of an application, dynamic, etc. But I'm just wondering what the best way to go here? Is it horrible to have to much JavaScript "squashed" to one document? How do you know where to draw the line when thinking about this?

share|improve this question
    
Is it three different views of the same content (different filters, etc) or is it three different pages (like home, help, about us)? –  R0MANARMY Jul 22 '12 at 3:26
    
different content –  Eric Vi4ing Jul 22 '12 at 3:51
    
If it's logically different content it would make more sense for it to be on different pages. –  R0MANARMY Jul 22 '12 at 3:52
    
There is no objective 'better' in this context. Its purely a matter of your preference on how to display the information. –  GrandmasterB Jul 22 '12 at 3:57
    
If that's the case I will go with JavaScript, because it makes things all in the same place for the viewer, and doesn't have to navigate different pages. –  Eric Vi4ing Jul 22 '12 at 4:00
show 2 more comments

2 Answers

up vote 6 down vote accepted

The downsides you need to consider if you go with the "all on one page, swapped using Javascript" approach:

  • Will people be able to bookmark or link to specific pages of information?
  • Will people be able to use their browser's back/forward buttons to navigate between pages on your site?
  • Will people with Javascript disabled (small but non-zero population) be able to use your site at all?
  • Will Google and other search engines be able to spider and index your content?

None of these problems are insurmountable, but they're all problems you won't have if you follow the traditional decades-old model of putting separate pieces of content on separate pages.

share|improve this answer
2  
It is possible to fix all 4 problems with the javascript page. –  Zachary K Jul 22 '12 at 7:56
2  
@ZacharyK: indeed, like I said, "None of these problems are insurmountable". –  Carson63000 Jul 23 '12 at 0:25
add comment

A good maintainable approach or practice to follow would be using master page layout. While having separate content pages that are linked through your master page.

Here is a reference how to set it up, if you use pure HTML and CSS - Using a Master Page to create a 2 column CSS layout.

If you are using Visual Studio then you may also find it useful to look at the followings:

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.