如何创建JavaScript关闭链接

Whenever I create a small JavaScript popup window, I offer a "close" link. Since I'm responsible for the new window, I feel it's my job to help them easily get rid of it.

每当我创建一个小JavaScript弹出窗口时,我都会提供一个“关闭”链接。 由于我负责新窗口,因此我认为帮助他们轻松摆脱它是我的工作。

XHTML (The XHTML)

Create an anchor with the JavaScript "close" call in the "href" attribute:

使用“ href”属性中JavaScript“ close”调用创建锚点:

Close Window

Do not use the onClick attribute of the anchor because not everyone clicks links.

不要使用锚点的onClick属性,因为不是每个人都单击链接。

Note: I've gotten out of the habit of using JavaScript popups. They're annoying and as smooth as steel wool. I recommend using a modal box via JavaScript. Most modal box scripts allow for smooth transitions and are just as easy to close as popup windows -- plus, they don't get blocked by popup blockers. I currently use MoodalBox for my projects.

注意:我已经摆脱了使用JavaScript弹出窗口的习惯。 它们令人讨厌并且像钢丝绒一样光滑。 我建议通过JavaScript使用模式框。 大多数模态框脚本都允许平滑过渡,并且与弹出窗口一样容易关闭-此外,它们不会被弹出窗口阻止程序阻止。 我目前在我的项目中使用MoodalBox

翻译自: https://davidwalsh.name/javascript-close

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值