title: Return to previous page in joomla
body: <p>I have created my own extension. This extension can be accessed from different components and parts of the website.</p>
  
  <p>The problem I have is that there could be a number of different URLs that link to this extension. I have a 'cancel' button and I can't work out how I would get this button to link to the previous URL.</p>
  
  <p>Wondering if there is something built into joomla like getPreviousURL? Couldn't find anything.</p>
  
  <p>EDIT: I should have said that I still want to be able to run my cancel() method. e.g. index.php?option=com_mycomp&amp;task=mycomp.cancel. The cancel() method will then perform a redirection to the previous page.</p>