gpt4 book ai didi

javascript - 使用 javascript 在同一选项卡中打开 url

转载 作者:行者123 更新时间:2023-11-30 18:11:09 25 4
gpt4 key购买 nike

我在 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");
}
}

发送post请求的函数:

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...没有成功..

最佳答案

去掉这一行;

form.setAttribute("target", name);

关于javascript - 使用 javascript 在同一选项卡中打开 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14560497/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com