问题描述
我试图将多个IP摄像机的图像导入到一个页面中。然而,相机为观众服务的脚本在每台相机上都有相同的名称,所以我似乎无法在一页上显示两个观众。是否有可能使用某种AS别名导入脚本,以便知道要执行的两个脚本中的哪一个?
在下面的伪代码中,我显示了我完全意味着(我制作了AS =cam1和cam1。~~)
< html>
< head>
< title>安全相机< / title>
< / head>
< body>
< script AS =cam1type ='text / javascript'src ='http://192.168.1.10:80 / jsv / SncViewer.js'>< / script>< script> cam1 .SNC.writeViewer({SZ: '4',PTZ: '1',FPS: '15',IPS: '1'})< /脚本>
< script AS =cam2type ='text / javascript'src ='http://192.168.1.20:80 / jsv / SncViewer.js'>< / script>< script> cam2 .SNC.writeViewer({SZ: '4',PTZ: '1',FPS: '15',IPS: '1'})< /脚本>
< / body>
< / html>
预先致谢
).on('ready')为此 - 此外它没有经过测试!
$(窗口) .load(函数(){
/ **
*加载
的IP数组*空相机= {} object
*用于内部名称间距
** /
var Ips = [192.168.1.10:80,192.168.1.20:80],
Suffix =/jsv/SncViewer.js,
Cameras = { };
/ **
*对于每个IP,从
* IP Array获取脚本,将保存的变量/ SNC
*保存在Camera.camX中。
** /
for(var x = 0; x $ .getScript({
url:http://+ Ips [x] +后缀+,
成功:函数(数据){
//可能是data.writeViewer ..!
相机['cam'+ x +''] =
SNC.writeViewer({sz:'4',ptz:'1',fps:'15',iPS:'1'});
}
});
}
});
//预期输出。
Cameras = {
cam1:// SNC Obj,
cam2:// SNC Obj
}
I'm trying to import the image of multiple IP cameras into one page. However, the script the camera serves for the viewer has the same name on every camera so i cannot seem to display both the viewers on one page. Would it be possible to import the scripts with a sort of AS alias so it knows which of the 2 scripts to execute?
In the below pseudo-code I show what i exactly mean (i made up the AS="cam1" and the cam1.~~)
<html>
<head>
<title>Security Cameras</title>
</head>
<body>
<script AS="cam1" type='text/javascript' src='http://192.168.1.10:80/jsv/SncViewer.js'></script><script>cam1.SNC.writeViewer({sz:'4',ptz:'1',fps:'15',iPS:'1'})</script>
<script AS="cam2" type='text/javascript' src='http://192.168.1.20:80/jsv/SncViewer.js'></script><script>cam2.SNC.writeViewer({sz:'4',ptz:'1',fps:'15',iPS:'1'})</script>
</body>
</html>
Thanks in advance
I'm guilty for using jQuery here, also I've chosen $(window).load
over $(document).on('ready')
for this - furthermore it's untested!
$(window).load(function() {
/**
* Array of IPs to load
* Empty Cameras = {} object
* for Internal name-spacing.
**/
var Ips = ["192.168.1.10:80", "192.168.1.20:80"],
Suffix = "/jsv/SncViewer.js",
Cameras = {};
/**
* For each IP, get script from
* IP Array, Keep the saved variable/SNC
* within Camera.camX.
**/
for( var x = 0; x < Ips.length; x++ ) {
$.getScript({
url: "http://"+ Ips[x] + Suffix +"",
success: function( data ) {
//May be data.writeViewer..!
Cameras['cam'+ x +''] =
SNC.writeViewer({sz:'4',ptz:'1',fps:'15',iPS:'1'});
}
});
}
});
//Expected Output.
Cameras = {
cam1 : //SNC Obj,
cam2 : //SNC Obj
}
这篇关于HTML多个Javascript别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!