参考这个问题:How to make the Web Bluetooth Pair button work when run as chrome app
在我的测试中,调用 navigator.bluetooth.requestDevice 时弹出的窗口非常大,覆盖了完全调用它的 html 窗口,并且包含 Pair 和 Cancel 按钮的窗口底部不在底部屏幕等不可见。
是否可以控制 requestDevice 窗口的位置和位置?
<html>
<head>
<script type="text/javascript" src="bluetoothle.js"></script>
<script type="text/javascript" src="popup.js"></script>
</head>
<body>
<h1>Hello Bluetooth</h1>
<h2>Device Discovery</h2>
<button id="btn_discover">Discover Devices</button>
<div id="devices"></div>
</body>
</html>
navigator.bluetooth.requestDevice(options)
.then(device => {
console.log('> Name: ' + device.name);
console.log('> Id: ' + device.id);
console.log('> Connected: ' + device.gatt.connected);
bluetoothle.selected_device = device;
console.log(bluetoothle.selected_device);
})
.catch(error => {
console.log('ERROR: '+ error);
});