Js SIP 代码在网页上不起作用
Js SIP code does not work on Web Page
'use strict';
/**
* Created by tqcenglish on 15-8-12.
* 若请静态文件使用默认账号,若添加参数则需要服务器动态生成此文件
*/
(function () {
var createScriptElement = function (src, onload, onerror) {
var element = document.createElement("script");
element.type = "text'/javascript";
element.src = src;
element.onload = onload;
element.onerror = onerror;
return element;
};
var createLinkElement = function (src) {
var element = document.createElement('link');
element.href = src;
element.rel = 'Stylesheet';
element.media_type = 'text/css';
return element;
};
var createUI = function () {
var clickCallDiv = document.createElement('div');
clickCallDiv.style.cssText = 'width: 300px;height: 60px;position: fixed;z-index: 999;right: 20px;bottom: 320px;';
var call_btn = document.createElement("button");
call_btn.id = "dial_btn_call";
var session_div = document.createElement("div");
session_div.id = 'sessions';
var webcam_div = document.createElement("div");
webcam_div.style.cssText = 'height:0';
webcam_div.id = 'webcam';
var video_remote = document.createElement('video');
video_remote.id = 'remoteView';
video_remote.autoplay = 'autoplay';
video_remote.hidden = 'hidden';
var video_local = document.createElement('video');
video_local.autoplay = 'autoplay';
video_local.hidden = 'hidden';
video_local.muted = 'muted';
video_local.id = 'selfView';
webcam_div.appendChild(video_remote);
webcam_div.appendChild(video_local);
clickCallDiv.appendChild(call_btn); //add the text node to the newly created div.
var contain = document.createElement('div');
contain.appendChild(session_div);
contain.appendChild(webcam_div);
clickCallDiv.appendChild(contain);
return clickCallDiv;
};
var urls = {};
urls.rtcninja = 'location/rtcninja.js';
urls.jquery = 'location/jquery.js';
urls.i18n = "location/jquery.i18n.js";
urls.messagestore = "location/jquery.i18n.messagestore.js";
urls.jssip = 'location/jssip.js';
urls.init = 'location/init.js';
urls.gui = 'location/gui.js';
urls.css = 'location/style.css';
var rtcninja_script = createScriptElement(urls.rtcninja, function () {
// Must first init the library
rtcninja();
// Then check.
if (!rtcninja.hasWebRTC()) {
console.log('WebRTC is not supported in your browser :(');
} else {
document.body.appendChild(createUI());
}
});
var jquery_script = createScriptElement(urls.jquery, function(){
document.head.appendChild(i18_script);
document.head.appendChild(jssip_script);
document.head.appendChild(gui_script);
document.head.appendChild(init_script);
});
var i18_script = createScriptElement(urls.i18n, function(){
document.head.appendChild(messagestore_script);
});
var messagestore_script = createScriptElement(urls.messagestore);
var jssip_script = createScriptElement(urls.jssip);
var init_script = createScriptElement(urls.init);
var gui_script = createScriptElement(urls.gui);
var click_call_css = createLinkElement(urls.css);
document.head.appendChild(jquery_script);
document.head.appendChild(rtcninja_script);
document.head.appendChild(click_call_css);
})();
上面的代码在HTTPS Web服务器上完美运行。问题是,我们的网站在HTTP服务器上运行。我做了一些修改,实验和很多研究,但同样的结果发生了。当我将按钮嵌入我们的网站时,它不会出现。我无法跟踪有关这些代码的任何错误。有什么问题吗?任何建议都会对我有很大帮助。谢谢。
顺便说一下,此代码应该能够通过我们办公室的电话拨打电话。 单击该按钮会将用户定向到Web RTC,该RTC将直接致电我们的办公室。
Chrome 不允许在 HTTP 上使用 WebRTC。您必须使用 HTTPS 或使用 Firefox 进行测试。
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 我的点击登录在网页上不起作用
- 网页按价格排序下拉菜单不起作用
- 使用 jquery 在我的网站中加载其他网页不起作用
- 当我尝试在网页中使用更新面板时,CSS不起作用
- 网页Jquery下拉按钮不起作用
- 网页中的JavaScript不起作用
- 动态创建的网页不起作用
- jQuery $this 在网页上不起作用
- 在网页上按“输入”键在镶边上不起作用
- AngularJS ng-repeat在Django驱动的网页上不起作用
- 我网页上的 JavaScript 在 IE 9 中不起作用有什么原因吗?
- 滑动在HTML5网页中不起作用
- 简单的 ajax GET 请求在我的 Django 网页上不起作用
- 尝试制作一个类似于终端外壳的网页,为什么会出现这种情况'不起作用
- jQuery转换是否可能在繁重的网页上不起作用
- Android-将值从应用程序传递到网页视图页面不起作用
- Js SIP 代码在网页上不起作用
- . getelementbyid().值在窗体's隐藏字段asp.net网页中不起作用
- 向网页中注入代码不起作用