summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/textfields.html
blob: b716006056383d76e94af66a250f516ac34fc7f3 (plain)
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
<!DOCTYPE HTML>
<html i18n-values='dir:textdirection;'>
<style>

html, body {
  margin: 0;
  overflow: hidden;
}

input {
  bottom: 0;
  left: 0;
  margin: 0;
  position: absolute;
  right: 0;
  top: 0;
}

</style>

<body>
  <input>
</body>

<script>

var textfield = document.querySelector('input');
textfield.addEventListener('input', sendTextfieldValueToBrowser);

/**
 * Sends the textfield value to the browser. Called whenever the user presses a
 * key. We first check if the key-press has really changed the text, then send
 * the new value to the browser if so.
 */
function sendTextfieldValueToBrowser() {
  chrome.send('textfieldValue', [textfield.value]);
}

/**
 * Sets textfield value
 * @param {string} value
 */
function setTextfieldValue(value) {
  textfield.value = value;
  sendTextfieldValueToBrowser();
}

</script>
</html>