我在"a"标签上跟踪onclick事件,onclick函数将获得"a"标签的href attr.我想检查href是绝对路径还是相对路径.是否有任何正则表达式来检查它.
然后是这种模式
"/myfolder/test.txt"
"http://example.com"
"https://example.com"
Run Code Online (Sandbox Code Playgroud)
这是我必须检查的其他模式.
我已经创建了一个套接字连接,并使用该连接将二进制流数据发送到服务器,并且在服务器端,我现在正在使用该数据获取二进制数据,我想创建一个视频文件并将其保存在服务器上。我已经成功地达到了获取二进制数据的目的,现在还无法将其转换为视频文件。请帮助实现。
在服务器端m上使用node.js创建套接字服务器,并从客户端javascript
服务器端代码:
var server = http.createServer(function(request, response) {
//Creating websocket server
});
server.listen(1337, function() { }); // listen to 1337 port
// create the server
wsServer = new WebSocketServer({
httpServer: server
});
// WebSocket server
wsServer.on('request', function(request) {
var connection = request.accept(null, request.origin);
// all messages from client will receive here.
connection.on('message', function(message) {
if (message.type === 'utf8') {
}else if (message.type === 'binary') {
//here i will get the binary data not want to create the video file …Run Code Online (Sandbox Code Playgroud) 我正在使用mutationObserver来检测使用以下代码的更改
var target = document.querySelector('body');
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
console.log(mutation.type);
});
});
var config = { attributes: true, childList: true, characterData: true };
observer.observe(target, config);
Run Code Online (Sandbox Code Playgroud)
在此,如果目标元素内部发生变化,我能够检测到变化,现在我正在瞄准身体
我真正想要的是mutationObserver事件仅在我指定的元素添加到DOM时触发
我在node.js中创建了api,它使用http://dev.abc.co.in:20081上托管的一组api, 不是每次都使用,但有时会随机抛出错误
Error: getaddrinfo ENOTFOUND dev.abc.co.in
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26) {
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'dev.abc.co.in'
}
Run Code Online (Sandbox Code Playgroud)
为了调用这些 api,我使用了请求节点模块,因为我开始收到此错误,我切换到 fetch-node npm 模块,最后用内部节点模块 http 替换代码,但收到相同的错误
这是我使用 http.request 编写的代码
try{
const options = {
hostname: "dev.abc.co.in",
port : 20081,
path: "/api/entity/workorder",
method: Config.method
};
if(Config.headers){
options.headers = Config.headers
}
const req = http.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
callback(res, data);
});
req.socket.destroy();
}).on("error", …Run Code Online (Sandbox Code Playgroud)