-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol-js.php
More file actions
38 lines (32 loc) · 907 Bytes
/
control-js.php
File metadata and controls
38 lines (32 loc) · 907 Bytes
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
<?php
if(!class_exists('Webview')) {
require_once "../webview.stub.php";
}
$webview = new Webview;
$webview->set_title("Hello Webview");
$webview->set_size(600, 450);
$webview->set_html("
<html>
<head>
<title>title</title>
</head>
<body>
<h1>Hello Webview</h1>
<p>This is a simple webview example.</p>
<button onclick='change_color()'>Change Color</button>
</body>
</html>
");
// Set initial color to red
$webview->init("
window.onload = function() {
document.body.style.backgroundColor = 'red';
}
");
$webview->bind("change_color", function() use ($webview) {
$colors = ['red', 'green', 'blue', 'yellow', 'purple', 'orange', 'pink', 'brown', 'black', 'white'];
$color = $colors[array_rand($colors)];
$webview->eval("document.body.style.backgroundColor = '{$color}'");
});
$webview->run();
unset($webview); // must clear