codecamp

window属性:onblur

onblur属性

该onblur属性表示该blur事件的对象的事件处理程序。它能够在Element,Document和Window中使用。

onblur属性语法

element.onblur = function;
  • function是用户定义的函数的名称,不带()后缀或任何参数或匿名函数声明,如下所示:
    element.onblur = function(){console.log(“onblur event detected!”); };

onblur属性示例

<html>

<head>
<title>onblur event example</title>

<script type="text/javascript">

var elem = null;

function initElement()
{
  elem = document.getElementById("foo");
  // NOTE: doEvent(); or doEvent(param); will NOT work here.
  // Must be a reference to a function name, not a function call.
  elem.onblur = doEvent;
};

function doEvent()
{
  elem.value = 'Bye-Bye';
  console.log("onblur Event detected!")
}
</script>

<style type="text/css">
<!--
#foo {
border: solid blue 2px;
}
-->
</style>
</head>

<body onload="initElement();">
<form>
<input type="text" id="foo" value="Hello!" />
</form>

<p>Click on the above element to give it focus, then click outside the
element.<br /> Reload the page from the NavBar.</p>

</body>
</html>
window属性:onbeforeunload
window属性:onchange
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Fetch API官方文档指南

Fetch API方法

WindowOrWorkerGlobalScope执行者:window

window属性

WindowOrWorkerGlobalScope执行者:WorkerGlobalScope

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }