onclick未捕获类型错误:无法读取属性 项目设置 Webstorm 2017.2 语言javascript,html 项目结构 源代码 index.html 预期行为 实际行为

onclick未捕获类型错误:无法读取属性 项目设置 Webstorm 2017.2 语言javascript,html 项目结构 源代码 index.html 预期行为 实际行为,javascript,html,onclick,buttonclick,Javascript,Html,Onclick,Buttonclick,这是我第一次尝试javascript项目。 我需要你们的帮助。伙计们,我发现了问题 起初的 固定的 它是由new引起的您不应该为WebSocket打开一个端口吗;不是。至少我从来都不这样。试试网络连接。_uproto__;。@NewToJS您知道,这个源代码还不需要网络套接字端口。@TyQ。不working@TyQ. 如果我更改按钮标记脚本webConnection.connectToServer->webConnection.connectToServer,则可以看到连接消息,但无法获取作为参

这是我第一次尝试javascript项目。
我需要你们的帮助。

伙计们,我发现了问题

起初的 固定的
它是由new引起的

您不应该为WebSocket打开一个端口吗;不是。至少我从来都不这样。试试网络连接。_uproto__;。@NewToJS您知道,这个源代码还不需要网络套接字端口。@TyQ。不working@TyQ. 如果我更改按钮标记脚本webConnection.connectToServer->webConnection.connectToServer,则可以看到连接消息,但无法获取作为参数地址、用户名等传递的数据添加:ws://192.168.33.30/jpeg/1/jpeg_stream.websock名称:admin pwd:admin onclick Uncaught TypeError:无法读取未定义的属性“connectToServer”`
.
├── Prototype
│   ├── Core
│   │   └── WebBroadcast.js
│   └── index.html
├── README.md
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Web player prototype</title>
    <script src="Core/WebBroadcast.js"></script>
</head>
<body>
    <div>
        <button type="button" onclick="webConnection.connectToServer()">Connect</button>
        <button type="button" onclick="webConnection.disconnectFromServer()">Disconnect</button>
    </div>
    <canvas id="webPlayer" width="640" height="480" style="border:1px solid #000000;"></canvas>

    <script>
        webConnection = WebConnection("ws://192.168.33.30/jpeg/1/jpeg_stream.websock", "admin", "admin", "webPlayer");
    </script>
</body>
</html>
function WebConnection(address, userName, userPassword) {
    console.log("add: " + address + " name: " + userName + " pwd: " + userPassword)
}

WebConnection.prototype.connectToServer = function () {
    console.log("connect")
}

WebConnection.prototype.disconnectFromServer = function () {
    console.log("disconnect")
}
add: ws://192.168.33.30/jpeg/1/jpeg_stream.websock name: admin pwd: admin
connect
add: ws://192.168.33.30/jpeg/1/jpeg_stream.websock name: admin pwd: admin
onclick Uncaught TypeError: Cannot read property 'connectToServer' of undefined
webConnection = WebConnection("ws://192.168.33.30/jpeg/1/jpeg_stream.websock", "admin", "admin", "webPlayer");
webConnection = new WebConnection("ws://192.168.33.30/jpeg/1/jpeg_stream.websock", "admin", "admin", "webPlayer");