
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
iframe-auto-height
Advanced tools
自动调整 iframe 的高度,主要用于商业项目的微访谈页面。
该模块会处理页面所有的 iframe,因此,即便页面上有多个 iframe 也没有问题。
示例:Demo
iframe 之间的通信使用了 postMessage
API,该 API 最低兼容到 IE8。
需要分别在 iframe 页面(即 child 页面)和引入 iframe 的页面(即 parent 页面)中调用
new AutoHeightChild()
和 new AutoHeight()
为完成初始化操作。
P.S. 上面之所以用
new
,是为了兼容旧版本的代码,统一风格。
具体到商业项目中,child 页面(即丁香客微访谈页面)中已经引入了该模块,我们所要做的只是在商业
项目中引入该模块,然后调用 new AutoHeight()
即可。
该模块已经发布到了 npm,可以通过下面的命令进行安装:
npm i iframe-auto-height --save
调用方法:
// 这一步需要在 iframe 页面中操作,丁香客页面中已经完成了这一步,无需我们操作
var AutoHeightChild = require('iframe-auto-height/child');
new AutoHeightChild();
// 这一步是需要我们添加到商业项目中的
var AutoHeight = require('iframe-auto-height/parent');
new AutoHeight();
<script>
或 $.getScript()
引入<script src="http://assets.dxycdn.com/third-party/AutoIframeHeight/2.0/child-min.js"></script>
<script>
new AutoHeightChild();
</script>
<script src="http://assets.dxycdn.com/third-party/AutoIframeHeight/2.0/parent-min.js"></script>
<script>
new AutoHeight();
</script>
同样,你也可以使用 $.getScript()
方法来动态加载脚本。
npm install
dist
目录中所有的 JS 文件到 svn 目录 assets/third-party/AutoIframeHeight/2.0
中,并
发布到线上注:步骤 4 发布到 npm 上时需要运行 npm version major|minor|patch
和 npm publish
这两个命令,
具体如何使用请参考 npm 的官方文档。
注:下面解释的这种情况仅做了解,一般不会这样使用。
如果通过 npm 安装后直接使用 require('iframe-auto-height')
来加载该模块的话会返回一个包含 Parent
和 Child
属性的对象,即:
var iframeAutoHeight = require('iframe-auto-height');
console.log(iframeAutoHeight.Child); // 等同于 AutoHeightChild
console.log(iframeAutoHeight.Parent); // 等同于 AutoHeight
同样,相应的还可以通过 <script>
来引入
http://assets.dxycdn.com/third-party/AutoIframeHeight/2.0/standalone-min.js
。
这样会在 window
上添加一个全局变量 IframeAutoHeight
,它里面包含 Parent
和 Child
两个属性。
用法和上面类似。
FAQs
自动调整 iframe 的高度,主要用于商业项目的微访谈页面。
The npm package iframe-auto-height receives a total of 4 weekly downloads. As such, iframe-auto-height popularity was classified as not popular.
We found that iframe-auto-height demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.