Browse AJAX Site Using Anchor

V

vunet

I've been thinking about how AJAX sites implement page browsing when
in fact the whole site is on one page. I know I may store page content
in array and add new content to this array as user clicks AJAX driven
links for the purpose of browsing history, etc. But what if I want to
share the page with somebody and AJAXed site always starts with the
main page.
I thought using anchor is the solution: www.mysite.com/#showHelpPage.
JavaScript would detect the URL and show the page according to anchor
(call showHelpPage page in my case). I would like to hea some thoughts
if possible and other consideration for this solution. Perhaps,
examples? Thanks.
 
B

Bart Van der Donck

vunet said:
I've been thinking about how AJAX sites implement page browsing when
in fact the whole site is on one page. I know I may store page content
in array and add new content to this array as user clicks AJAX driven
links for the purpose of browsing history, etc. But what if I want to
share the page with somebody and AJAXed site always starts with the
main page.
I thought using anchor is the solution:www.mysite.com/#showHelpPage.
JavaScript would detect the URL and show the page according to anchor
(call showHelpPage page in my case). I would like to hea some thoughts
if possible and other consideration for this solution. Perhaps,
examples? Thanks.

I think only anchors are possible here, because the script would
otherwise need a new HTTP-request in order to be able to change the
address bar [*].

But you should code out every anchor relatively and not absolutely
(#showHelpPage in stead of http://www.mysite.com/#showHelpPage). The
former stays on the same page, while the latter may fetch mysite.com
from its end-source again [*].

I would be cautious about memory consumption if the data becomes
somewhat larger.

[*] I'm not considering buffers and caches.

Hope this helps,
 
V

vunet

vunet said:
I've been thinking about how AJAX sites implement page browsing when
in fact the whole site is on one page. I know I may store page content
in array and add new content to this array as user clicks AJAX driven
links for the purpose of browsing history, etc. But what if I want to
share the page with somebody and AJAXed site always starts with the
main page.
I thought using anchor is the solution:www.mysite.com/#showHelpPage.
JavaScript would detect the URL and show the page according to anchor
(call showHelpPage page in my case). I would like to hea some thoughts
if possible and other consideration for this solution. Perhaps,
examples? Thanks.

I think only anchors are possible here, because the script would
otherwise need a new HTTP-request in order to be able to change the
address bar [*].

But you should code out every anchor relatively and not absolutely
(#showHelpPage in stead ofhttp://www.mysite.com/#showHelpPage). The
former stays on the same page, while the latter may fetch mysite.com
from its end-source again [*].

I would be cautious about memory consumption if the data becomes
somewhat larger.

[*] I'm not considering buffers and caches.

Hope this helps,

Thank you. While creating a test case I have trouble creating a
capture events function. This wouldn't work:

window.captureEvents(Event.CLICK);
window.onclick=PageStateManager.gotoPage;

Error: use of captureevents is deprecated
 
V

vunet

And

document.addEventListener('click',PageStateManager.gotoPage,false);

error is Could not convert JavaScript arguments. Is something wrong?
Can anyone suggest?
 
T

T.J. Crowder

I've been thinking about how AJAX sites implement page browsing when
in fact the whole site is on one page. I know I may store page content
in array and add new content to this array as user clicks AJAX driven
links for the purpose of browsing history, etc. But what if I want to
share the page with somebody and AJAXed site always starts with the
main page.
I thought using anchor is the solution:www.mysite.com/#showHelpPage.
JavaScript would detect the URL and show the page according to anchor
(call showHelpPage page in my case). I would like to hea some thoughts
if possible and other consideration for this solution. Perhaps,
examples? Thanks.

On some level, you may be reinventing the wheel:
http://code.google.com/p/reallysimplehistory/
 
S

shawn

You might as well throw in a flash intro screen and have all your
content as images-- do you plan on having search engines crawl / list
your site? Or does it degrade gracefully w/o javascript?

Shawn
 
V

vunet

You might as well throw in a flash intro screen and have all your
content as images-- do you plan on having search engines crawl / list
your site? Or does it degrade gracefully w/o javascript?

Shawn

Yes, SEO and AJAXed sites seem to be bad friends I know. I am afraid I
need to create 2 sites: for SEs and users separately.
 
H

Henry

Yes, SEO and AJAXed sites seem to be bad friends I know.
I am afraid I need to create 2 sites: for SEs and users
separately.

1. You are creating a web site for which bookmarking and search
engines are important.
2. You have decided to use AJAX.
3. Because you have decided to use a AJAX the bookmarking has become
unnatural and you are having to write an extended series of unreliable
javascript hacks to get beck to something close to what bookmarking
is.
4. Because you have decided to use AJAX the viability of what you are
making for search engines is minimal so you are contemplating creating
a second site that is viable for search engines.

There was a poor design decision somewhere in there. If the re-
inventing the square wheel of hacking you way back to bookmarking did
not tip you off that something was fundamentally wrong with your
design the suggestion of needing to create and maintain two sites in
parallel certainly should have.
 
V

vunet

1. You are creating a web site for which bookmarking and search
engines are important.
2. You have decided to use AJAX.
3. Because you have decided to use a AJAX the bookmarking has become
unnatural and you are having to write an extended series of unreliable
javascript hacks to get beck to something close to what bookmarking
is.
4. Because you have decided to use AJAX the viability of what you are
making for search engines is minimal so you are contemplating creating
a second site that is viable for search engines.

There was a poor design decision somewhere in there. If the re-
inventing the square wheel of hacking you way back to bookmarking did
not tip you off that something was fundamentally wrong with your
design the suggestion of needing to create and maintain two sites in
parallel certainly should have.

So you say if I want an AJAX'ed site I should forget about it being SE
friendly and visa versa if I want SE friendly site I should use AJAX
on a minimal level not to conflict with the valuable content?
Of course, I cannot say I'd do 2 sites. I'd create additional
functionality to keep users on one page and retrieve other content
with AJAX calls and search engines would simply crawl different
content with website template wrapped around it.
 
P

Peter Michaux

vunet said:
I've been thinking about how AJAX sites implement page browsing when
in fact the whole site is on one page. I know I may store page content
in array and add new content to this array as user clicks AJAX driven
links for the purpose of browsing history, etc. But what if I want to
share the page with somebody and AJAXed site always starts with the
main page.
I thought using anchor is the solution:www.mysite.com/#showHelpPage.
JavaScript would detect the URL and show the page according to anchor
(call showHelpPage page in my case). I would like to hea some thoughts
if possible and other consideration for this solution. Perhaps,
examples? Thanks.

I think only anchors are possible here, because the script would
otherwise need a new HTTP-request in order to be able to change the
address bar [*].

But you should code out every anchor relatively and not absolutely
(#showHelpPage in stead ofhttp://www.mysite.com/#showHelpPage). The
former stays on the same page,

Richard Cornford pointed out there is no technical justification to
believe setting the location.hash or any part of the location object
will not reload the page. Early versions of Safari display this
possibility. Please see the following thread in the archives.


while the latter may fetch mysite.com
from its end-source again [*].

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top