最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - How to setup a dynamic website with javascript only (no serverside) - Stack Overflow

programmeradmin0浏览0评论

Here's my problem: I want to build a website, mostly static but with some dynamic parts (a little blog for news, etc..). My webserver can only do static files (it's actually a public dropbox directory!) but I don't want to repeat the layout in every html page!

Now, I see two possible solutions here: either I create an index.htm page that emulates site navigation with javascript and AJAX or I create all the different html pages and then somehow import the layout bits with javascript..

From you I need ideas and suggestions on how to implement this, which libraries to use, or maybe there exists even something tailored exactly for what I need?

Thanks!!

Here's my problem: I want to build a website, mostly static but with some dynamic parts (a little blog for news, etc..). My webserver can only do static files (it's actually a public dropbox directory!) but I don't want to repeat the layout in every html page!

Now, I see two possible solutions here: either I create an index.htm page that emulates site navigation with javascript and AJAX or I create all the different html pages and then somehow import the layout bits with javascript..

From you I need ideas and suggestions on how to implement this, which libraries to use, or maybe there exists even something tailored exactly for what I need?

Thanks!!

Share Improve this question asked Nov 13, 2010 at 18:54 lucaluca 12.6k16 gold badges72 silver badges106 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 2

I would define the site layout in your index.html file, and then use JavaScript and Ajax to load the actual content into a content div on the page. That way your content files (fetched by Ajax) will be more or less plain HTML, with CSS classes defined in index.html. Also, I wouldn't remend building a blog in pure HTML and JavaScript. It wouldn't be very interactive; no ments, ratings, etc. You could store your blog content in XML and then fetch and display it with Ajax and JavaScript, however.

While on the subject of XML, you could implement all your site content in XML. You should also store the list of pages (for generating navigation) as XML.

Just another one way. You can generate static HTML in your puter and upload result to dropbox. Look at emacs muse.

jQuery allows you to easily load a section of one page into another page. I remend loading mon navigation sections into the different pages, rather than the other way around to avoid back/forward problems. Layout can be done with a separate CSS file rather than with tables to minimize the amount of repeated code. For the blog, you could put each blog entry in a separate file and load each section individually.

However, I would just use something already available. TiddlyWiki, for example, is a self-contained wiki that is all in one file. It's very customizable, and there's already a blog plug-in available for it. You can work on the site on your hard drive or USB drive, and then you can upload it to the web when done. There's nothing more to it.

Have you considered using publishing software on your puter to bine your content with a template, resulting in a set of static pages that you can then upload to the dropbox?

Some options in this regard e to mind:

  • Movable Type - can output static HTML which can then be uploaded to the server
  • Adobe Dreamweaver
  • Apple iWork Pages

To handle ments, you can use Disqus. It inserts a plete ment system into your site using just JavaScript.

You can use the Google Closure templates. It's one of the fastest and most versatile javascript templating solutions around.

发布评论

评论列表(0)

  1. 暂无评论