-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathweb_navigation.go
75 lines (60 loc) · 3.39 KB
/
web_navigation.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
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
package chrome
import "github.com/gopherjs/gopherjs/js"
type WebNavigation struct {
o *js.Object
}
/*
* Methods
*/
// GetFrame retrieves information about the given frame. A frame refers to an <iframe> or
// a <frame> of a web page and is identified by a tab ID and a frame ID.
func (w *WebNavigation) GetFrame(details Object, callback func(details Object)) {
w.o.Call("getFrame", details, callback)
}
// GetAllFrames retrieves information about all frames of a given tab.
func (w *WebNavigation) GetAllFrames(details Object, callback func(details []Object)) {
w.o.Call("getAllFrames", details, callback)
}
/*
* Events
*/
// OnBeforeNavigate fired when a navigation is about to occur.
func (w *WebNavigation) OnBeforeNavigate(callback func(details Object), filters map[string][]Object) {
w.o.Get("onBeforeNavigate").Call("addListener", callback, filters)
}
// OnCommited fired when a navigation is committed. The document (and the resources it refers to,
// such as images and subframes) might still be downloading, but at least part of the document has
// been received from the server and the browser has decided to switch to the new document.
func (w *WebNavigation) OnCommited(callback func(details Object), filters map[string][]Object) {
w.o.Get("onCommited").Call("addListener", callback, filters)
}
// OnDOMContentLoaded fired when the page's DOM is fully constructed, but the referenced resources may not finish loading.
func (w *WebNavigation) OnDOMContentLoaded(callback func(details Object), filters map[string][]Object) {
w.o.Get("onDOMContentLoaded").Call("addListener", callback, filters)
}
// OnCompleted fired when a document, including the resources it refers to, is completely loaded and initialized.
func (w *WebNavigation) OnCompleted(callback func(details Object), filters map[string][]Object) {
w.o.Get("onCompleted").Call("addListener", callback, filters)
}
// OnErrorOccurred fired when an error occurs and the navigation is aborted. This can happen if either a network
// error occurred, or the user aborted the navigation.
func (w *WebNavigation) OnErrorOccurred(callback func(details Object), filters map[string][]Object) {
w.o.Get("onErrorOccurred").Call("addListener", callback, filters)
}
// OnCreatedNavigationTarget fired when a new window, or a new tab in an existing window, is created to host a navigation.
func (w *WebNavigation) OnCreatedNavigationTarget(callback func(details Object), filters map[string][]Object) {
w.o.Get("onCreatedNavigationTarget").Call("addListener", callback, filters)
}
// OnReferenceFragmentUpdated fired when the reference fragment of a frame was updated. All future events for that frame will
// use the updated URL.
func (w *WebNavigation) OnReferenceFragmentUpdated(callback func(details Object), filters map[string][]Object) {
w.o.Get("onReferenceFragmentUpdated").Call("addListener", callback, filters)
}
// OnTabReplaced fired when the contents of the tab is replaced by a different (usually previously pre-rendered) tab.
func (w *WebNavigation) OnTabReplaced(callback func(details Object)) {
w.o.Get("onTabReplaced").Call("addListener", callback)
}
// OnHistoryStateUpdated fired when the frame's history was updated to a new URL. All future events for that frame will use the updated URL.
func (w *WebNavigation) OnHistoryStateUpdated(callback func(details Object), filters map[string][]Object) {
w.o.Get("onHistoryStateUpdated").Call("addListener", callback, filters)
}