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

Redirect And Cancel

$
0
0

Hey Guys, can you help with modify the mode below to go to a new url on cancel instead going back -1

<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+'/Lists/xyz/NewForm.aspx');
location.href = stringURL;
}

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

}

});

</script>​​



Viewing all articles
Browse latest Browse all 7589

Trending Articles



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