2017-05-23 38 views
0

我正在使用SharePoint 2013.我有一個用於反饋和建議的自定義列表表單。目前,要訪問表單,用戶點擊一個鏈接,直接將它們帶到新條目表單。SharePoint 2013:點擊取消按鈕後重定向到不同頁面

我試圖完成的事情: - 當用戶點擊保存時,他們被帶到一個「謝謝你」頁面。 - 當用戶點擊取消時,他們被帶回主頁。

我所做的事情: - 鏈接到新的形式,我加入了 - 這完成了保存按鈕的任務,而不是取消按鈕任務

「源=(網址爲致謝頁?」。

我需要什麼幫助:。 我需要知道如何覆蓋默認取消按鈕現在它也重定向到您的網頁我需要它去主頁的感謝

我唯一可以做的編輯表格是添加代碼片段。

在此先感謝!

+0

你可以編輯你的問題,幷包括取消按鈕的HTML標記。一個 –

+0

部分:<輸入名稱= 「ctl00 $ ctl31 $ g_528cf443_45bd_472c_80e7_9649548c1e91 $ ctl00 $ toolBarTbl $ RightRptControls $ ctl01 $ ctl00 $ diidIOGoBack」 類= 「MS-ButtonHeightWidth」 ID = 「ctl00_ctl31_g_528cf443_45bd_472c_80e7_9649548c1e91_ctl00_toolBarTbl_RightRptControls_ctl01_ctl00_diidIOGoBack」 ACCESSKEY = 「C」 的onclick =「STSNavigate(」 HTTPS://thankyou.aspx');返回false; WebForm_DoPostBackWithOptions(新WebForm_PostBackOptions兩個 –

+0

部分:(" ctl00 $ ctl31 $ g_528cf443_45bd_472c_80e7_9649548c1e91 $ ctl00 $ toolBarTbl $ RightRptControls $ ctl01 $ ctl00 $ diidIOGoBack "," ",真實," ", " ",false,true))「type =」button「value =」取消「target =」_ self「> –

回答

0

要做到這一點,我做了以下內容:

要保存按鈕被按下後重定向:

  1. 創建感謝您網頁然後複製網址。留着以後用。
  2. 添加「?source =」,然後將第1步中的網址添加到可將您帶到新項目頁面的鏈接末尾。 EX:https://NewItemForm.aspx?Source=https://ThankYou.aspx

這將重定向到謝謝頁面,如果你點擊保存或取消。

要解決的取消按鈕,請執行下列操作,以及:

  1. 轉到您的列表>表單Web部件(功能區)>默認新形式
  2. 插入腳本編輯器Web部件
  3. 添加以下代碼:

<script> 
 

 
function goToByePage(){ 
 
    window.location.assign("https://SitePages/Home.aspx"); 
 
} 
 

 
function overrideCancel() 
 
{ 
 
\t //Custom input button 
 
\t var input = document.createElement('input'); 
 
\t input.type = "button"; 
 
\t input.name = "Cancel"; 
 
\t input.value = "Cancel"; 
 
\t input.id = "custominput"; 
 
\t document.querySelectorAll('.ms-toolbar input[value=Cancel]')[1].parentNode.appendChild(input); 
 
\t document.getElementById("custominput").setAttribute("class", "ms-ButtonHeightWidth"); 
 
\t 
 
\t //Hiding already implemented cancel buttons 
 
\t document.querySelectorAll('.ms-toolbar input[value=Cancel]')[0].style.display = "none"; 
 
\t document.querySelectorAll('.ms-toolbar input[value=Cancel]')[1].style.display = "none"; 
 
\t 
 
\t //this is main logic to move history back 
 
\t document.getElementById("custominput").setAttribute("onclick", "goToByePage();"); 
 
} 
 

 

 

 
_spBodyOnLoadFunctionNames.push('overrideCancel'); 
 
</script> 
 

 
<style> 
 
#Ribbon\.ListForm\.Edit\.Commit\.Cancel-Large 
 
{ 
 
\t display:none; 
 
} 
 
</style>

這將刪除功能區中的上取消按鈕,並使表單上的取消按鈕返回到goToByePage函數中列出的任何頁面。

此代碼來自2個不同的來源:

https://sharepoint.stackexchange.com/questions/190776/basic-custom-list-how-to-redirect-to-different-page-on-cancel-and-on-save-butto

https://social.msdn.microsoft.com/Forums/office/en-US/5036ab40-2d9b-4fe5-87a2-5805268eea07/how-to-override-behavior-of-the-cancel-button-in-the-ribbon-and-the-form?forum=sharepointdevelopment

希望這可以幫助別人,將來別人!

相關問題