0

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重定向。

+0

为什么setTimeout的? –

+0

对于Firefox,需要setTimeout.without setTimeout,点击按钮在firefox中无法正常工作。 – GokulPgp

回答

0

之前,你做任何事情,先试试这个:

 document.getElementById("yourElementName").addEventListener("click", function(event){ 
        event.preventDefault() 
     }); 
+0

我不明白,请简单说一下。 – GokulPgp

+0

你正在删除一个元素的点击,它很好。但是,您还必须防止该元素的点击默认行为。所以,通过首先应用我的答案,您可以禁用该默认行为。之后,执行你想要的。 –