FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
WebViewJavascriptBridge/ExampleApp/ExampleApp.html at master · xzeror/WebViewJavascriptBridge · GitHub
This repository was archived by the owner on Feb 12, 2019. It is now read-only.
xzeror
/
WebViewJavascriptBridge
Public archive
forked from
marcuswestin/WebViewJavascriptBridge
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
WebViewJavascriptBridge
/
ExampleApp
/
ExampleApp.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (62 loc) · 2.29 KB
Breadcrumbs
WebViewJavascriptBridge
/
ExampleApp
/
ExampleApp.html
Copy path
File metadata and controls
66 lines (62 loc) · 2.29 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<!doctype html
>
<
html
>
<
head
>
<
style
type
='
text/css
'
>
html
{
font-family
:
Helvetica;
color
:
#
222
; }
h1
{
color
:
steelblue;
font-size
:
24
px
;
margin-top
:
24
px
; }
button
{
margin
:
0
3
px
10
px
;
font-size
:
12
px
; }
.
logLine
{
border-bottom
:
1
px
solid
#
ccc
;
padding
:
4
px
2
px
;
font-family
:
courier;
font-size
:
11
px
; }
</
style
>
</
head
>
<
body
>
<
h1
>
WebViewJavascriptBridge Demo
</
h1
>
<
script
>
window
.
onerror
=
function
(
err
)
{
log
(
'window.onerror: '
+
err
)
}
document
.
addEventListener
(
'WebViewJavascriptBridgeReady'
,
onBridgeReady
,
false
)
function
onBridgeReady
(
event
)
{
var
bridge
=
event
.
bridge
var
uniqueId
=
1
function
log
(
message
,
data
)
{
var
log
=
document
.
getElementById
(
'log'
)
var
el
=
document
.
createElement
(
'div'
)
el
.
className
=
'logLine'
el
.
innerHTML
=
uniqueId
++
+
'. '
+
message
+
(
data
?
':<br/>'
+
JSON
.
stringify
(
data
)
:
''
)
if
(
log
.
children
.
length
)
{
log
.
insertBefore
(
el
,
log
.
children
[
0
]
)
}
else
{
log
.
appendChild
(
el
)
}
}
bridge
.
init
(
function
(
message
,
responseCallback
)
{
log
(
'JS got a message'
,
message
)
var
data
=
{
'Javascript Responds'
:
'Wee!'
}
log
(
'JS responding with'
,
data
)
responseCallback
(
data
)
}
)
bridge
.
registerHandler
(
'testJavascriptHandler'
,
function
(
data
,
responseCallback
)
{
log
(
'ObjC called testJavascriptHandler with'
,
data
)
var
responseData
=
{
'Javascript Says'
:
'Right back atcha!'
}
log
(
'JS responding with'
,
responseData
)
responseCallback
(
responseData
)
}
)
var
button
=
document
.
getElementById
(
'buttons'
)
.
appendChild
(
document
.
createElement
(
'button'
)
)
button
.
innerHTML
=
'Send message to ObjC'
button
.
ontouchstart
=
function
(
e
)
{
e
.
preventDefault
(
)
var
data
=
'Hello from JS button'
log
(
'JS sending message'
,
data
)
bridge
.
send
(
data
,
function
(
responseData
)
{
log
(
'JS got response'
,
responseData
)
}
)
}
document
.
body
.
appendChild
(
document
.
createElement
(
'br'
)
)
var
callbackButton
=
document
.
getElementById
(
'buttons'
)
.
appendChild
(
document
.
createElement
(
'button'
)
)
callbackButton
.
innerHTML
=
'Fire testObjcCallback'
callbackButton
.
ontouchstart
=
function
(
e
)
{
e
.
preventDefault
(
)
log
(
'JS calling handler "testObjcCallback"'
)
bridge
.
callHandler
(
'testObjcCallback'
,
{
'foo'
:
'bar'
}
,
function
(
response
)
{
log
(
'JS got response'
,
response
)
}
)
}
}
</
script
>
<
div
id
='
buttons
'
>
</
div
>
<
div
id
='
log
'
>
</
div
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL