# DOM

The current state-of-the-art is to put scripts in the <head> tag and use the async or defer attributes. This allows your scripts to be downloaded asap without blocking your browser.

The good thing is that your website should still load correctly on the 20% of browsers that do not support these attributes, while speeding up the other 80%.

# 禁止 Alert()

覆写 window 的 alert 方法。

window.alert = function() {};

// or simply
alert = function() {};

// change to console.log
alert = function() {
  console.log(arguments[0])
}

# 获取背景图片URL

// 方案一
(window.getComputedStyle(element).getPropertyValue("background-image")).replace('url(','').replace(')','');

// 方案二
element.style.backgroundImage.match(/url\((.*)\?/)[1]

# 获取带回车的纯文本

window.clipboardData.getData(“Text”)

# 按钮防止重复点击

// 防重复点击
$this.attr('disabled', true).text('创建中…').css('opacity', '0.7')
$this.attr('disabled', false).text('更新会议').css('opacity', '1')

# 键盘事件

# 禁止缩放

Last Updated: 5/14/2022, 11:38:45 AM