0.0.7 • Published 3 years ago

iframe-storage v0.0.7

Weekly downloads
16
License
MIT
Repository
-
Last release
3 years ago

iframe-storage

proxy your iframe storage to parent, to fix some local storage issues in iOS Safari. link

scan to visit the demo

npm.io

How it work:

 ----------------------------------------
|  domainA     storage                   |
|                  ^                     |
|                  |   postmessage       |
|    -------------------------------     |
|   | domainB      |                |    |
|   |              V                |    |
|   |          a fake storage       |    |
|   |                               |    |
-----------------------------------------

install

npm i iframe-storage

or insert directly

top page, make sure insert it before your iframe. any where is ok
<script src="https://cdn.jsdelivr.net/npm/iframe-storage@0.0.6/dist/ifrStorage.js"></script>
iframe
<script src="https://cdn.jsdelivr.net/npm/iframe-storage@0.0.6/dist/ifrStorageCli.js"></script>

usage

top page

import "iframe-storage/src/ifrStorage"

iframe:

import {init} from "iframe-storage/src/ifrStorageCli"

init({scope:"demo"}).ready(function (){
  localstorage.test=1  
})

ifrStorageCli config

nametypedefaultdesc
targetwindowwindow.topuse target's storage
scopestringto isolate storage, empty means use parent's storage directly
targetOriginstring丨array*postmessage's targetOrigin
localStoragebooleantruehandle localStorage
sessionStoragebooleantruehandle sessionStorage
whenfunctionnullexecute if return true ,empty means always execute
readyfunctionnullsame as init().ready(fn)
0.0.7

3 years ago

0.0.5

3 years ago

0.0.6

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago