-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.html
More file actions
29 lines (24 loc) · 1.13 KB
/
client.html
File metadata and controls
29 lines (24 loc) · 1.13 KB
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
<div>
<div>Client Page</div>
</div>
<script src="dist/browser.js"></script>
<script type="text/javascript">
const remoteOriginStorageclient = IframeStorage.constructClient({
iframe: {
// src: "http://127.0.0.1:5101/hub.html", -- for local testing
src: "https://iframe-shared-storage.vercel.app/hub.html",
messagingOptions: { enableLog: 'both' },
iframeReadyTimeoutMs: 1000
},
});
console.log('client constructed:', remoteOriginStorageclient);
async function exampleSetAndGet() {
await remoteOriginStorageclient.localStorage.setItem('foo', 'bar ' + Math.random());
const value = await remoteOriginStorageclient.localStorage.getItem('foo');
console.log('Got value localStorage via hub:', value);
await remoteOriginStorageclient.indexedDBKeyval.set('foo-indexed-db', 'value-indexed-db ' + Math.random());
const idbValue = await remoteOriginStorageclient.indexedDBKeyval.get('foo-indexed-db');
console.log('Got value from IndexedDB via hub:', idbValue);
}
</script>
<button onclick="exampleSetAndGet()"> send </button>