views:

46

answers:

2

hi all, first im sorry about my poor english..

ok, i have 3 page with different concept/layout/animation

im use prototype & scriptaculous

i have this in my navigation:

<ul>
<li><a href="#page1" id="page1" onClick="showPage(page1);">PAGE1</a></li>
<li><a href="#page2" id="page2" onClick="showPage('page2');">PAGE2</a></li>
</ul>

and this is in my js:

windows.location.hash: 'web';

function showPage() {
startloading();
var url: '/localhost/page2'+web;
new Ajax.Updater('maincontent', 'page2', { method: 'get' });
finishloading();
}

the question & problem are:

  1. why in windows location hash is still: /localhost/page1/#page2 with or without if i use var url?
  2. all the animation in page 2 doesn't work, because i didn't put the header, but if put i it, i got double header and still the animation want work either.

can anybody give me the solution?

thank you very much.

A: 

The correct way to update your hash is:

window.location.hash = '#'+yourValue;

Hard to tell what exactly you're trying to do with your function but there's a few things that are clearly a bit wrong.

function showPage(var) { 
    startloading();
    var url: '/localhost/page'+var;
    new Ajax.Updater('maincontent', url, { method: 'get' });
    finishloading();
}

depending on what you're actually doing its fairly likely you would probably want something more like this:

function showPage(var) {         
    var url = '/localhost/page'+var;
    new Ajax.Updater('maincontent', url, { method: 'get' ,
        onCreate: function(){
            startloading();
        },
        onComplete: function(){
            finishloading();
        }
    });
}

Thats complete guesswork though, if you can provide more detail i can help more.

seengee
A: 

In your code

var url: '/localhost/page2'+web;

line throws error so hash cannot be changed. Fix it to

var url = '/localhost/page2'+web;

then it should work.

Serkan Yersen