title image


Smiley Re: Button soll immer einen Anker weiter springen?
Hi,



das ist über reines HTML leider nicht möglich sondern nur über clientseitiges JavaScript (Online-Demo):



index.html







<html>

<head>

</head>

<frameset cols="30%,70%">

<frame name="navigation" src="navigation.html">

<frame name="content" src="content.html">

</frameset>

</html>







navigation.html







<html>

<head>

<script language="JavaScript">

<!--



function zapp_next()

{

//"ankers" ;-)

var frame = parent.content;

var ankers = frame.document.getElementsByTagName("a");



if(akt_anker_index == ankers.length-1)

{

akt_anker_index = -1;

}



for(var i = 0; i<ankers.length; i++)

{

var url = frame.location.href;



var hash_pos = url.indexOf("#");



if(hash_pos > -1)

{

url = url.substring(0,hash_pos);

}



url += "#" + ankers[i].name;



if(i > akt_anker_index)

{

akt_anker_index = i;

frame.location.href = url;

break;

}

}

}



function zapp_back()

{

//"ankers" ;-)

var frame = parent.content;

var ankers = frame.document.getElementsByTagName("a");



if(akt_anker_index == 0)

{

akt_anker_index = ankers.length;

}



for(var i = ankers.length-1; i>=0; i--)

{

var url = frame.location.href;



var hash_pos = url.indexOf("#");



if(hash_pos > -1)

{

url = url.substring(0,hash_pos);

}



url += "#" + ankers[i].name;



if(i < akt_anker_index)

{

akt_anker_index = i;

frame.location.href = url;

break;

}

}

}



var akt_anker_index = 0;

var frame_address = "content.html";



//-->

</script>

</head>

<body>

<h1 style="text-align:center;">Navigation</h1>

<p style="text-align:center;">

<input type="button" value="Vor" onClick="zapp_next();">&nbsp;&nbsp;

<input type="button" value="Zurück" onClick="zapp_back();">

</p>

</body>

</html>







content.html





<html>

<head>

</head>

<body>

<h1 style="text-align:center;">Content</h1>

<a name="anker1"></a><b>Anker 1</b>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<a name="anker2"></a><b>Anker 2</b>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<a name="anker3"></a><b>Anker 3</b>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<a name="anker4"></a><b>Anker 4</b>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<a name="anker5"></a><b>Anker 5</b>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

<p>Text</p>

</body>

</html>







MfG Murdoch!

aktuelle Winamp Playlist                Hörgewohnheiten (Last.fm)



geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: