【发布时间】:2018-09-12 12:08:32
【问题描述】:
您好,我遇到了重定向问题。
我有一个 API,当我点击图片时会调用它,它会获取用户联系号码并从软件拨打电话。
一切正常,但问题是,API 重定向到我不想要的其他页面。
我只想显示呼叫消息,但焦点应保持在同一页面上。
这是我的 xhtml 代码:
Cell No.
<h:outputText value="#{informationManagerBean.cust.cellNo}" styleClass="textColorChange"/>
Direct Dial
<h:outputLink style="margin: 25px" id="tool_dial" onclick="PF('callDialog').show();
{
return true;
}" value="http://199.199.333.94/calling.php" >
<img src="Resources/images/dialer.png" alt="NR Letter" align="top" style="margin: 25px"/>
<f:param name="cli" value="#{informationManagerBean.cust.cellNo}" />
<f:param name="userid" value="000001" />
</h:outputLink>
<p:dialog id="callDialog1" onShow="myFunction();" onHide="myStopFunction();" header="Calling..."
width="200px" widgetVar="callDialog"
position="center" draggable="true" resizable="false" closable="false"
closeOnEscape="true" appendTo="@(body)" modal="true">
</p:dialog>
这里是 java 脚本:
<script>
var myVar;
function myFunction()
{
myVar = setTimeout(function() {
PF('callDialog').hide()
}, 3000);
}
function myStopFunction()
{
clearTimeout(myVar);
}
</script>
谢谢
【问题讨论】:
-
你试过
onclick="PF('callDialog').show(); return false;"吗?return false抑制进一步的操作,即 goto href。 -
@Holger in outlin 我用过,如果我用false它不会拨打电话,只显示消息
-
啊,抱歉,calling.php 执行调用....
-
<p:commandLink actionListener="#{mybean.mycallFn()}" ajax="true" partialSubmit="true" process="@this" oncomplete="PF('callDialog').show()"/>和 mybean.mycallFn() 你使用 URLConnection 就像在答案中 -
@Holger 喜欢答案吗?
标签: javascript php html jsf primefaces