SharePoint中的回发重定向在Chrome和Firefox中正常工作。但IE 11的重定向工作不正常。在IE中,后台只在控制台打开后才能工作
我已经使用的JavaScript代码如下
var publishButton = $("input[id$=SaveItem]");
// change redirection behavior
publishButton.removeAttr("onclick");
publishButton.on('click',function() {
var elementName = $(this).attr("name");
var aspForm = document.forms['aspnetForm'];
var oldPostbackUrl = aspForm.action;
if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false;
var currentSourceValue = GetUrlKeyValue("Source", true, oldPostbackUrl);
var newPostbackUrl = _spPageContextInfo.webAbsoluteUrl+"/Lists/Posts/Post.aspx";
var newPostbackUrl = oldPostbackUrl.replace(currentSourceValue,newPostbackUrl);
if (!PreSaveItem()) return false;
setTimeout(function(){
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", newPostbackUrl, false, true));
},1);
});
推荐想法IE做11重定向。
为什么setTimeout的? –
对于Firefox,需要setTimeout.without setTimeout,点击按钮在firefox中无法正常工作。 – GokulPgp