Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Redirect to New URL Script

$
0
0

Hello I have the code below that allows you to redirect to a new URL when the form is save. It works but whenever click add new item it reloads the page twice. Can someone help me fix this?

<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script> ​​​<br/><script type="text/javascript">

$(document).ready(function(){

$("input[value='Cancel']").attr('onclick','');

$("input[value='Cancel']").click(function(){

location.href = _spPageContextInfo.webAbsoluteUrl; // It will redirect you to home page after clicking on cancel button

});

var stringURL = location.href;
if(stringURL.indexOf("AllItems")>-1){
stringURL = stringURL.replace(stringURL.substring(stringURL.indexOf("Source="),stringURL.length),'Source='+_spPageContextInfo.webAbsoluteUrl+'/SitePages/ThankYou.aspx');
location.href = stringURL;
}

if(!(stringURL.indexOf("Source=")>-1)){
location.href = location.href+"?Source="+_spPageContextInfo.webAbsoluteUrl+'/SitePages/ThankYou.aspx';

}

});

</script>​​​


nk


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>