Node js Book Example From the following door
Onload becomes an alert window
There's no button event ㅜ It's not even in the log. It doesn't even pop up in the console window.
When clicking a button
Developer Console Window
Uncaught TypeError: Cannot read property 'length' of undefined naver_dic.js:1046
This error occurs.
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="/socket.io/socket.io.js"></script>
<script>
window.onload = function(){
alert("onload");
var socket = io.connect();
socket.on('smart',function(data){
alert(data);
});
document.getElementById('button').onClick = function(){
alert('button click');
};
};
</script>
</head>
<body>
<input type="text" id="text" />
<input type="button" id="button" name="button" value="echo" />
</body>
</html>
onClick
https://jsfiddle.net/kuvq32vL/
onclick
https://jsfiddle.net/kuvq32vL/1/
This is the sample code that annotated only sockets in the code you wrote above.
If you look at the link, you can check that it is working normally.
Even if you look at naver_dic.js:1046
among the error messages you added later,
Considering that there is no information related to naver_dic.js in the above code
The reason is expected to be the other parts that are not included in the code you uploaded.
Appears to be a case study.
Try modifying to onclick
instead of onclick
~
Note:
https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onclick
© 2024 OneMinuteCode. All rights reserved.