1

我尝试了一些东西但没有得到任何东西..当我点击删除链接时,我必须得到一个确认框,但我没有得到它..有人可以建议我吗?

JSP

urlencrypt:url value="abc.action" htmlEscape="true" var="removeLink"/>
<td><a href="removeLink"  onclick="confirmRemoveQuestion('${removeLink}')">
<fmt:message key="link.remove" /></a>&nbsp;&nbsp;&nbsp;&nbsp;</td>

javascript

<script type="text/javascript">
var confirmRemoveDialog;
var confirmOkUrl=  ; 

function setRemoveQuestionDialog()
{
    var handleYes = function() { 
        window.location = confirmOkUrl;
        this.hide(); 
    };

    var handleNo = function() { 
        this.hide();
    };

    var confDialogButtons = [ { text:"<fmt:message key="link.cancel"/>", handler:handleNo, isDefault:true}, 
                                { text:"<fmt:message key="link.ok"/>",handler:handleYes } 
                              ];

    confirmRemoveDialog = getConfirmOKDialog(confDialogButtons);
}

function confirmRemoveQuestion(url)
{
    confirmOkUrl = url;
    setRemoveQuestionDialog();
    showConfirmDialog(confirmRemoveDialog, "<fmt:message key="removeLink.confirmMessage"/>");
}
</script>
4

2 回答 2

2

使用以下简单代码

<script>
function confirmRemoveQuestion(link){
    if(show_confirm()){
     window.location = link;
     this.hide(); 
    }
    else{
     this.hide();  
    }
}
function show_confirm()
{
  return confirm("Are you sure you want to do this?");
}
</script>

<td><a href="#"  onclick="confirmRemoveQuestion('${removeLink}')"> <!--removLink-->
<fmt:message key="link.remove" /></a>&nbsp;&nbsp;&nbsp;&nbsp;</td>
于 2013-11-14T05:04:39.230 回答
1

你知道吗

showConfirmDialog(confirmRemoveDialog, "<fmt:message key="removeLink.confirmMessage"/>");

语法不正确?调试会告诉你这一点。

于 2013-11-14T05:01:40.950 回答