使用javascript在同一个标​​签页中打开网址

时间:2013-01-28 10:56:33

标签: javascript

我在worklistManager.jsp中有一个按钮,它调用一个函数(getWorklistManagerModify())..该函数在utility.js文件中,然后执行一些操作并重定向到worklist.jsp页面及其响应..如何在worklistManager.jsp的相同选项卡或同一窗口中打开worklist.jsp页面。现在它作为单独的选项卡打开。

getWorklistManagerModify函数:

function getWorklistManagerModify(){
    var whereCondn = "";
    //alert(gbshowgridFlag);
    if(dijit.byId('finderResponseGridCWPWORKLIST')){
        var selctedItem = dijit.byId('finderResponseGridCWPWORKLIST').selection.getSelected();
        if(selctedItem.length){
            dojo.forEach(selctedItem, function(selectedItem){
                if(selectedItem !== null){
                    dojo.forEach(dijit.byId('finderResponseGridCWPWORKLIST').store.getAttributes(selectedItem), function(attribute){
                        var value = dijit.byId('finderResponseGridCWPWORKLIST').store.getValues(selectedItem, attribute);
                        //alert(value);
                        if(attribute == "CWDOCID"){
                            whereCondn = whereCondn+attribute+"="+value;
                        }
                        //alert(whereCondn);
                    });
                    var cols= "DUE_DATE,PRIORITY,CWDOCID";
                    var ioArgs = {
                            url: "./DynamicDBServlet",
                            content: { TABLE_NAME:'CWPWORKLIST',WHERE_CONDN:whereCondn,COLUMNS:cols,ACTION:'select'}, 
                            handleAs: "text",
                            load: function(response) {
                            postRequestPage("worklist.jsp",response,'title');

                            },
                            error: function(error) {
                                alert("An unexpected error occurred: " + error);
                            }
                    };
                    var deferred = dojo.xhrPost(ioArgs);

                }
            });
            //alert("grid row selected");
        }else{
            alert("Please select a task");
        }
    }
    if(gbshowgridFlag==false){
        alert("Please select a task");
    }
}

发送帖子请求的功能:

function postRequestPage(url, params, name){
    alert(params);
    var form = document.createElement("form");
    form.setAttribute("method", "post");
    form.setAttribute("action", url);
    form.setAttribute("target", name);
    var input = document.createElement('input');
    input.type = 'hidden';
    input.name = "PARAM";
    input.value = params;
    form.appendChild(input);
    document.body.appendChild(form);
    window.location.href = url;
    //window.open(url,"_self");
    form.submit();
    document.body.removeChild(form);
}

我尝试使用window.location.href,window.open,location.href和window.location ......没有成功..

1 个答案:

答案 0 :(得分:2)

删除此行;

form.setAttribute("target", name);