Eerste zinnetjes in die link die je geeft is niet interessant, daarna zegt hij dat je een frame moet maken waar je de echte pagina in propt (genaamd "window") en eentje waar je onderstaande javascript in stopt.
Eerste stuk geeft dus de daadwerkelijk scriptcode weer, het onderstaaste stukje definieer je wanneer de verschillende functies worden aangeroepen, in dit geval dus als gevolg van het klikken op een hyperlink. "foobar.html" geeft dus de naam van de pagina weer die geopend moet worden in het frame window wanneer je op die link klikt.
JavaScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
| function History(target)
{
var items = [];
var currentItem = 0;
this.goto =
function history_goto(sURL)
{
items[currentItem++] = target.location;
target.location = sURL;
};
this.go =
function history_go(n)
{
if (currentItem + n < 0 || currentItem + n > items.length - 1)
{
if (n < 0)
n = -currentItem;
else
n = items.length - 1 - currentItem;
}
target.location = items[currentItem += n];
};
this.back =
function history_back()
{
this.go(-1);
};
this.forward =
function history_forward()
{
this.go(+1);
};
}
/*
* The non-function properties of the prototype are accessible
* via the function properties, the methods, only. If you need
* direct access, declare them as properties of `this' instead.)
*/
if (parent)
{
if (!parent.history)
// Let the history be a property of the parent frameset;
// navigation affects the location of the current frame (window)
parent.history = new History(window);
}
function checkProp(sProp)
{
return (parent && parent.history && parent[sProp]);
}
function back()
{
if (checkProp("back"))
parent.history.back();
return false;
}
function forward()
{
if (checkProp("forward"))
parent.history.forward();
return false;
}
function goto(sURL)
{
if (checkProp("goto"))
parent.history.goto(sURL);
return false;
} |
HTML:
1
2
3
4
| <a href="#" onclick="return back();">Back</a>
<a href="#" onclick="return forward();">Forward</a>
...
<a href="foobar.html" onclick="return goto(this.href);">Next</a> |
[
Voor 16% gewijzigd door
hufkes op 05-06-2007 17:30
]