I need help to use a javascript to navigate between the different segments of a HTML file.
What I want to do is:
1.I have a HTML frame, in the top frame, it contains two button “Next” and “Previous”;
2.In the Bottom frame, it is a normal html file like:
This is first one;
This is second one;
This is third;
This is end;
3.What I want to do is if I click the Next button in top frame, the cursor will go to first sentence (just like an internal link), click again, go to second sentence, if I click “Previous”, then it go back to first sentence again.
4.To do that, I think I need to first add some unique id for each sentence, I add something like <meta name=”a1”> <meta name=”a2”>, then add a javascritp code in top frame.
My top frame – button.html looks like:
<html>
<head>
<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
function goToSeg() { need to add real code for this function}
// End –>
</script>
</head>
<body>
<form>
<p align=”right”>
<input type=button value=”Previous” onClick=”goToSeg()”>
<input type=button value=”Next ” onClick=”goToSeg()”>
</form>
<p> <p>
</body>
</html>
And the bottom frame – test.html looks like
<html>
<head>
<title>Test</title>
</head>
<body>
<meta name=”a1″> 1. This is first one.</meta>
<meta name=”a2″> 2. This is second one. </meta>
<meta name=”a3″> 3. This is third one. </meta>
</body>
</html>
Now, can anybody tell me how to right a javascipt function to navigation the different sentence (let the cursor to the sentence inside meta tag) in bottom html page? Or the way I use for this solution (put the meta in the sentence I want to navigate) is not the best way.
Any help will be great appreciated!
Andrew