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?
-
Is it three different views of the same content (different filters, etc) or is it three different pages (like home, help, about us)?Roman– Roman2012年07月22日 03:26:56 +00:00Commented Jul 22, 2012 at 3:26
-
different contentEric Vi4ing– Eric Vi4ing2012年07月22日 03:51:31 +00:00Commented Jul 22, 2012 at 3:51
-
If it's logically different content it would make more sense for it to be on different pages.Roman– Roman2012年07月22日 03:52:28 +00:00Commented Jul 22, 2012 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– GrandmasterB2012年07月22日 03:57:23 +00:00Commented Jul 22, 2012 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– Eric Vi4ing2012年07月22日 04:00:19 +00:00Commented Jul 22, 2012 at 4:00
2 Answers 2
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.
-
2It is possible to fix all 4 problems with the javascript page.Zachary K– Zachary K2012年07月22日 07:56:22 +00:00Commented Jul 22, 2012 at 7:56
-
2@ZacharyK: indeed, like I said, "None of these problems are insurmountable".Carson63000– Carson630002012年07月23日 00:25:16 +00:00Commented Jul 23, 2012 at 0:25
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: