-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathhistory.go
46 lines (35 loc) · 1.08 KB
/
history.go
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
package godom
// This file implements History interface
// https://developer.mozilla.org/en-US/docs/Web/API/History
import (
"github.com/gopherjs/gopherjs/js"
)
type History struct {
*js.Object
}
// Properties
// https://developer.mozilla.org/en-US/docs/Web/API/History/length
func (h *History) Length() int {
return h.Get("length").Int()
}
// Methods
// https://developer.mozilla.org/en-US/docs/Web/API/History/back
func (h *History) Back() {
h.Call("back")
}
// https://developer.mozilla.org/en-US/docs/Web/API/History/forward
func (h *History) Forward() {
h.Call("forward")
}
// https://developer.mozilla.org/en-US/docs/Web/API/History/go
func (h *History) Go(p int) {
h.Call("go", p)
}
// https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_pushState()_method
func (h *History) PushState(stateObj interface{}, title, url string) {
h.Call("pushState", stateObj, title, url)
}
// https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
func (h *History) ReplaceState(stateObj interface{}, title, url string) {
h.Call("replaceState", stateObj, title, url)
}