也测试一下 memos 的嵌入
| // markdown 文章主页面 | |
| <iframe id="memos_223" style="width:100%;height:500px;min-width:256px;" src="https://memos.onmicrosoft.cn/m/223/embed" frameBorder="0"></iframe> | |
| <script> | |
| ( | |
| function () { | |
| // 接收从iframe发来的消息并获取高度 | |
| window.addEventListener('message', event => { | |
| if (event.data.type === 'iframeHeight') { | |
| // log | |
| console.log('iframeHeight:', event.data) | |
| memos_223.style.height = event.data.height + 'px' | |
| } | |
| }) | |
| } | |
| )(); | |
| </script> | |
| // memos 页面自定义js | |
| setInterval(() => { | |
| const height = window.document.body.offsetHeight | |
| window.parent.postMessage({ | |
| type: 'iframeHeight', | |
| height: height | |
| }, '*') | |
| }, 1000) |
Code By ChatGPT.
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 ZkeqのCoding日志!
评论




