Javascript-显示命令链接,然后消失
Javascript - showing a commandLink and then Disappearing
我正在开发JSF应用程序,想要一个简单的函数-单击commandbutton并显示commandLink。我做了一个测试。代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<script type="text/javascript">
function testfunc() {
document.getElementById("testForm:test").style.display="block";
document.getElementById("testForm:test").style.visibility="visible";
}
</script>
</head>
<body>
<h:form id = "testForm" >
<h:panelGroup id="test" style="display:none" >
<h:commandLink value="Page 1" action="page1" /><br/>
</h:panelGroup>
<button onclick="testfunc()">Click me</button>
</h:form>
</body>
</html>
问题是显示的链接-<h:commandLink value="Page 1" action="page1" />
立即消失。有人有什么建议吗?非常感谢!
我将您的xhtml更改为,它可以工作。我将按钮的类型改为按钮,而不是默认的提交。我还把body改成了h:body。你可以像我一样保留panelGroup或使用panelGrid。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<script type="text/javascript">
function testfunc() {
document.getElementById("testForm:test").style.display="block";
document.getElementById("testForm:test").style.visibility="visible";
}
function hidefunc() {
document.getElementById("testForm:test").style.display="none";
document.getElementById("testForm:test").style.visibility="hidden";
}
</script>
</head>
<h:body>
<h:form id = "testForm" >
<h:panelGrid id="test" style="display:none" >
<h:commandLink value="Page 1" action="page1" /><br/>
</h:panelGrid>
<button onclick="testfunc()" type="button">Show me</button>
<button onclick="hidefunc()" type="button">Hide me</button>
</h:form>
</h:body>
</html>
相关文章:
- 将display属性更改为visible flicks,然后再次消失
- Javascript:选择页面上的所有复选框.它会检查所有内容一秒钟,然后消失
- 闪烁文本几秒钟 - 然后消失
- Ng-重复不起作用的表达显示,然后立即消失
- 在 jsp 中使用简单 ajax 时出现问题 - 内容填充然后消失
- 对话框出现,然后消失
- 为什么当用户单击背景时,我的jQuery Mobile页脚会出现然后消失
- 网页中的图像会出现一小段时间,然后消失
- jQuery.fadeOut淡出为一种颜色,然后消失
- 在JavaScript onClick中:为什么笔划出现然后消失
- Javascript-显示命令链接,然后消失
- 流星助手添加适当的css一秒钟,然后消失
- 是否有一种方法来阻止隐藏文本出现时加载,然后消失
- JQuery悬停-叠加出现.相反,客户端希望覆盖在那里,然后消失与悬停
- Div在jquery/javascript中出现几秒钟然后消失
- jQueryUI datepicker -当show()被调用时,第二个实例闪烁然后消失
- 图像闪烁然后消失
- JavaScript id输出只显示一秒钟,然后消失
- Javascript-值存在,然后消失,然后再次出现
- 形态短暂地克隆,然后消失