Kees C. Bakker
Kees C. Bakker

Reputation: 33431

JavaScript navigation to named hyperlink

I have the following hyperlink:

<a name="top"></a>

My button looks like this:

<span id="listControl_1_ctl15" onclick="window.location='#top'" class="TextButton">
    <span class="button_left"></span>
    <span class="button_text">Bovenaan</span>
    <span class="button_right"></span>
</span>

My page doesn't navigate to the top section. Does anyone know why?

Upvotes: 1

Views: 102

Answers (3)

Stefan Koenen
Stefan Koenen

Reputation: 2337

put this on what you call the top:

<a name="top"></a> 

and then you can use this to go to the link

<a href= "#top"> go to the top </a>

if you want to go to the top of the whole page you can use this also:

<a href = #> TOP! </a>

stefan.

Upvotes: 4

rogal111
rogal111

Reputation: 5933

Use window.location.hash :

<span id="listControl_1_ctl15" onclick="window.location.hash='top'" class="TextButton">
    <span class="button_left"></span>
    <span class="button_text">Bovenaan</span>
    <span class="button_right"></span>
</span>

Upvotes: 3

soju
soju

Reputation: 25322

You should use hash :

window.location.hash='top'

Upvotes: 2

Related Questions