javascript to add source URL
<p>I am using the following code in CEWP (content editor webpart) so after taking a survey user will be redirected to thank you page. the redirecting is not working. Am I missing something? (user able to take survey and newform.aspx never closes)</p>

<pre><code>&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"&gt;&lt;/script&gt;  
&lt;script type="text/javascript"&gt;  
 function PreSaveAction(){  
     var URL = location.pathname.replace("NewForm.aspx","/surveys/Pages/ThankYou.aspx");  
     if(GetUrlKeyValue("IsDlg")==="1"){  
         URL+="?IsDlg=1";  
     }  
     $("#aspnetForm").attr("action",location.pathname+"?Source="+URL);  
     return true;  
 }  
&lt;/script&gt; 
</code></pre>
