【发布时间】:2021-02-18 14:42:12
【问题描述】:
我目前正在开发一个计算机电话集成系统,该系统将手机连接到网络界面。可以使用 http 命令从 SNOM 手机拨打电话:“http://admin:password@[phone ip address]/command.htm?number=[phonenumber]”。这可以正常工作,除了它会打开一个重定向到 SNOM 索引页面的新窗口 - 我正在尝试停止此重定向,但仍然可以进行调用。
我没有直接在浏览器中输入 URL,而是有一个链接,用户可以按下该链接开始通话:
<a target="popup" onclick="dial()">Dial</a>
链接调用 dial() 函数,该函数使用 window.open() 传递相应的 url。
以下是我试图“隐藏”或伪装新打开的标签的内容:
- 使用 window.open() 然后实现 x 毫秒的超时,然后使用 .close() 关闭选项卡
=> 页面打开并拨打了号码但没有关闭 - 使用 window.document.open().write() 更改 SNOM 索引页面的内容,使其显示“拨号号码” => 这正确地重写了页面,因此至少它掩盖了弹出窗口,但它改变了 url到 about:blank 并且听筒不拨号
- 使用 window.blur() 或将窗口“left”/“top”参数设置为 10000 以将其移出页面 => 这也不起作用,它只是将其移到角落。
- 应用 iframe 隐藏框架 => 这会导致更多错误
- 我尝试了许多 AJAX 表单/方法,但都没有走多远。
为了尝试解决这个问题,我访问了以下 stackoverflow 链接:
- Make a ping to a url without redirecting
- Hidden window using javascript
- sending an url but staying on the same page ( php, codeigniter, javascript )
简而言之,我需要能够调用 URL -“http://admin:password@[phone ip address]/command.htm?number=[phonenumber]”并隐藏弹出窗口、立即关闭弹出窗口但仍然拨打电话,或者重写页面以伪装它。
下面是代码:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<style>
a {
padding:.5em;
background-color:rgb(55,55,55);
color:white;
text-decoration:none;
font-weight:lighter;
cursor:pointer;
}
</style>
<body>
Call Number
<br>
<input name = 'number' id = 'number' type = 'number'>
<br><br>
<a target="popup" onclick="dial()">Dial</a>
</body>
<script>
function dial() {
var num = $('#number').val();
str1 = 'http://admin:password@[ip address]/command.htm?number=9'
var url = str1.concat(num);
var x = window.open(url,'_blank', 'toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,left=-20000, top=20000, width=10, height=10, visible=none').blur();
/*
w.document.open().getElementById('body').innerHTML="<body fontFamily = 'Raleway' bgColor='red' text='white'><table><tr><td><img src= 'https://www.sexologistdoctorindelhi.com/images/call.gif' style = 'height:120px;margin-left:-40px;margin-right:-30px;margin-top:-20px;'</td><td><h1 style = 'margin-top: -15px;'> Dialling</h1><p style = 'margin-top:-20px;'> "+num+"</p></td><title>WWS</title></body>";
*/
}
</script>
</html>
【问题讨论】:
-
这里是否将
visibility: hidden;放在弹出窗口中? -
您可以将可见性设置为无,但这似乎没有任何效果。我认为在新的浏览器中,一些文档或方法已经过时了。这是窗口对象的链接:w3schools.com/jsref/obj_window.asp
-
可见性:隐藏不起作用:(
-
嗯,iframe 是一个选项而不是窗口对象吗?
标签: javascript html url telephony