123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- html,
- body {
- margin: 0;
- padding: 0;
- width: 100%;
- height: 100%;
- }
- </style>
- </head>
- <body>
- <input type="text" name="" placeholder="width" id="width"> <br>
- <input type="text" name="" placeholder="height" id="height"><br>
- <input type="text" placeholder="url" name="" id="url"><br>
- <input type="button" value="确定"id="btn">
- <script>
- window.onload = (e) => {
- let _input_url = document.querySelector('#url')
- let _input_width = document.querySelector('#width')
- let _input_height = document.querySelector('#height')
- let _input_btn = document.querySelector('#btn')
- let data = {}
- _input_btn.addEventListener('click',()=>{
- data.width = _input_width.value
- data.height = _input_height.value
- data.url = _input_url.value
- window.parent.postMessage(JSON.stringify(data), '*')
- })
- window.addEventListener('message', function (e) {
- if (e.data) {
- let item = JSON.parse(e.data)
- _input_url.value = item.url || ''
- _input_width.value = item.width || ''
- _input_height.value = item.height || ''
- }
- }, false)
- }
- </script>
- </body>
- </html>
|