Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Ajax Programming

Creating a static header, left-hand menu, and footer.

Hi everyone.

I would like to create my first totally AJAX-enabled website. However,
I am not sure if I can do some of the things I would like to do.

I would like to have a static header, footer and index column at the
left (as with most sites), and only change the content within the main
body of the page. Just to clarify:

    <table width="100%">
      <tr colspan="2">
          This is the header.

        <td width="150px">
          This is the left-hand menu.
          This is where the main content will go.

        <td colspan="2">
          Footer Here.

The code above is a rought template for all pages on my website. What I
would like is for the header, left-hand menu and footer to stay as they
are (just like there would if I used frames), and for the main content
to change dynamically. Perhaps this isn't the best way to do it, but I
can't see why not. My main problem is users bookmarking pages. I don't
think they will be able to, so I think I might not be using AJAX

What I would like to be able to do is update the user's address bar
with a URL, but not actually load that page. Is there a way I can
acheive the results I am looking for, but by using AJAX and not frames?
Does anyone know of a good AJAX powered site where I might be able to
see some good examples?

Many thanks.


You can not change the address bar without going to a new page


On 1/6/07, Daz <cutenfu@gmail.com> wrote:

On Jan 6, 6:20 pm, "Daz" <cutenfu@gmail.com> wrote:

What you need to do if you want to give the user something to bookmark
is use the hash of the address. Javascript can change the hash by using
window.location.hash = "whatever"

If you don't get what I mean by that just set up a simple page with
three buttons, each one's onclick could be "window.location.hash =
'1';", etc. and then you'll see what i mean.

So that allows people to save a particular state of your site. The fun
part comes in programming your code to remember this state. The way to
do this is to use the onload event. When the event fires your function,
you check the hash with if (window.location.hash == 'whatever') and
then you change the page's middle text to be whatever you want. There
are quite a few examples out there, just search for 'ajax', 'bookmark',
'state' and similar terms on google or whatever.

BUT, do you need an ajax website? Excuse me if I'm patronising you
here, but do you realise that you can have this permanent
header/nav/footer in pages without resorting to javascript by use of
php, asp, or whatever? If you don't know any of these server-side
languages it's not that hard to learn enough to get this header/footer
business going. What you'll need is something like the following:

In PHP (the language I use):

1 file called header.php containing:

    <table width="100%">
      <tr colspan="2">
          This is the header.
        <td width="150px">
          This is the left-hand menu.

1 file called footer.php containing:

        <td colspan="2">
          Footer Here.

and then in each content page of your site (index.php, \bout.php,
contact.php, whatever) you have something like this:

<?php include("header.php"); ?>

Main content goes here

<?php include("footer.php"); ?>

That will give you your constant header/nav and footer through each
page, whilst keeping everyone as one downloaded page for the user.
Also, beacuse everything's on a separate page the user can bookmark to
their will.

Again, sorry if you are experienced in this stuff and just wanted to
know about ajax, but I thought I'd cover all of the bases.



Yes and no. To be honest, I am not entirely sure if I want users to be
able to bookmark any pages. My website is going to be a game, not what
I would call a regular site.

> Excuse me if I'm patronising you
> here, but do you realise that you can have this permanent
> header/nav/footer in pages without resorting to javascript by use of
> php, asp, or whatever?

No, I don't find you patronising in the slightest. I know I am
seriously pushing the envelope to a level where it just might bite me
in the butt, but there are several things I would like to be updating
in almost real time. For example, a JavaScript chat applet will be
running in another frame in the background. If someone else in the
applet mentions the users name, I want the user to be notified within
5-10 seconds, even if they don't refresh the page. There are two many
sites around which try to be interactive, but rely on pages refreshes
too much, which can be seriously annoying. That's web 1.0 as we know
it. Pages are lifeless (apart from any animations you might have on the
page). It relys too much on the user to help themselves to the
responses (if you know what I mean). If you automatically refreshed the
page, you risk seriously ticking off the user. With pages updating
automatically, and behind the scenes, however, in such a way that it's
seamless. I think it has more potential to wow users than tick them

There will be a few HTML pages, but not many, and those pages will only
be used if the user doesn't have JavaScript enabled. Other than that,
once the user logs in, I would like everything to run just like an
application. Also, I think it will be better for the server to only
send out small amounts of data, and also more responsive for the user.
In case you have already seen it, check out www.netvibes.com. This is
an example of a site that doesn't work without Ajax, yet it's good
enough to make you want to keep it enabled. I think JavaScript is a
pretty safe language to use, as you can't really do much intentional
damage at the users end due to restrictions, and therefore, there's
really no reason to disable it (IMHO).

I guess I just want to embrace the Web 2.0 revolution, and take full
advantage of it with Web 3.0 just around the corner. There may also be
one or two large-ish applications which would be best not loaded from
the server every time they are needed. I think I will do a Google, and
use an iframe to store the scripts. Just out of interest, have you ever
used GMail? It's pretty good. Although when you refresh, you get logged
in again. There is limited support for the back button, but I have
found the navigation to be good enough to not need to use either
refresh or the back button. That back button can be dangerous if used
incorrectly. It can resubmit post data, thus posting something more
than once, and having the potential to 'undo' changes that have already
been made. This is why I have decided to make my page navigation clear,
and easy, so the back button will become obsolete within my app. I am
sure, that with a little JavaScript, I can catch the users back button
presses, and alert them with a message. (inspired by the demo at
http://www.youos.com). I am sure you'll agree, the conept is excellent.

I am hoping to make a game like nothing anyone has ever seen before.
The user will need to keep JavaScript enabled in order to use it, but I
am hoping that the site will be that good that users are prepared to
keep it enabled. A lot of users don't even know how to disable
JavaScript on their browsers. Yes, it's daring, but I like to be
different. If you wanted to play a really good game on your PC, and it
wouldn't work because you didn't have Direct X installed, or something
similar, what would you do? My instinct is to think that you would do
what you need to in order to play it. I know I would. :)

Thank you very much for your input. I really appreciate it. :)

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc