I build my website by using html and javascript ( I have no access to php ), and the thing is that as most of the websites, it contains a header, and a bottom that it is the same in all the pages.
For me, the simplest solution was to create a javascript
that inserts the html content by using document.write()
.
So the content of my html pages is something like this:
<head>
non relevant code
</head>
<script type="text/javascript" src="-javascript/websites_top.js"></script>
Page content..
<script type="text/javascript" src="-javascript/websites_bottom.js"></script>
This principle works pretty good, but I realized that when the content takes some time to load there is an annoying problem..
The problem:
The website has the following structure:
+------------------+
| MENU |
+----+--------+----+
|td1 | td2 |td3 |
| | | |
| | | |
+----+--------+----+
| Bottom |
+------------------+
So websites_top.js
: ends on <td>
(td2), and websites_bottom.js
starts on </td>
(td2)
The problem is that when the content of the html page takes some time to load, the website is displayed like this:
+-------------+
| MENU |
+----+--------+
|td1 | td2 |
| | |
| | |
+----+--------+
Until the html content finish of loading. ( the content of each page )
I'm currently searching a solution to this, and I've thought the following fixes:
1) Mix websites_top.js
and websites_bottom.js
, and inserting the html content of the td by using another javascript. Option that I would like to avoid because this would mean that all the html content should be a javascript string and that's annoying. Also I'm afraid that search engines have problems reading the content of the page, since all will be written as a javascript string.
2) Do some sort of preloading. The problem with this is that I don't want to preload all the pages of the website, so how would I know which one does the user will click?
I tough in making a script for my menu, something like: on click preload, and then send to the page.
For the programming I think that the solution 2 its better, but for the users and the website I think that the solution 1 its better because there will be no "lag" when switching between pages.
What do you think? Is there a better way of doing this? (without php or shtml includes, my "server" its pretty basic)