function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
krupananda reddykrupananda reddy 

Navigate to home tab from visualforce page ?

I have visusalforce button, on click of it navigation should go back to home tab. i.e. /home/home.jsp. I tried this with javascript and pagereference method. With page reference method nothing is happening, but with js it saying "URL no longer exists."  Below is the js i used,
var returnURL;
		window.onload =  function() {
			returnURL = gup('retURL');
		};    
		function redirectBack() {
			window.location.href = '/' + returnURL;
		}
Pagerefernece i used ,
pageRef = new PageReference('/home/home.jsp');
return pageRef;
Any help is appreciated. Thanks in advance.
Nitin PaliwalNitin Paliwal
Hi,
Try this with the pageReference method:

PageReference pageRef = new PageReference('/home/home.jsp');
pageRef.setRedirect(true);
return pageRef;

Thanks
Nitin
krupananda reddykrupananda reddy
Nothing happens, still the same. It stays in same page. I have tried this already.
Nitin PaliwalNitin Paliwal
Please provide me with the commandButton code, what you have return, and the Action method on the controller code.

Thanks
Nitin
krupananda reddykrupananda reddy
<apex:commandButton value="Cancel" reRender="pgbbb" status="MyStatuss" action="{!redirectToPreviousPage}"/> 

public PageReference redirectToPreviousPage() {
    	PageReference pageRef;
             pageRef = new PageReference('/home/home.jsp');
             pageRef.setRedirect(true);
    	     return pageRef;  
}

 
krupananda reddykrupananda reddy
Hey nitin, I was able to figure out a solution by JS. Thanks Man.
venkatasubbareddy adurivenkatasubbareddy aduri
Could you please share the solution krupananda reddy