This learning JavaScript

Study the code, retained for later see
<html>

<head>

<title>JS֮Thisѧϰ</title>

</head>

<body>
<input name="btnName" type="button" value="button" onclick="introduce();" />
<input name="btnName2" type="button" value="button2" />
<img src="apple.png" onerror="alert(1);} function hi() { alert(2); " />
<script type="text/javascript">
var name = "I am Laruence";
function introduce() {
alert(this.name);
}
alert(window.introduce);
document.getElementById('btnName2').onclick = introduce;
dom.onclick = introduce();
</script>
</body>


</html>

Started by Lorraine at December 18, 2016 - 11:03 AM

The top post ~ access points~

Posted by Amber at December 27, 2016 - 11:42 AM

About the contents of the this
You can also have a look
.apply( {} , {} )
.call( {} , {} )
There are Ajax in the this domain

Posted by Elijah at December 30, 2016 - 12:42 PM

Give you a small example


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<script type="text/javascript">
var name = 'b';
function test() {
this.name = 'a';
b();
}
function b() {
alert(this.name);
}
</script>
<body>
<!- try, the first point of test1, and then press the test2. And then refresh the page, and then point test1-- to point test2,>
<input type="button" value="test1" onclick="test()" />
<input type="button" value="test2" onclick="b()" />
</body>
</html>

Posted by Bishop at January 03, 2017 - 12:58 PM