Search code examples
javascriptphpjoomla

integrating history.back(-1) in php code


I'm not a php developer and I have a basic knowledge in html.

I currently have this code

<div class="page-header">
			<h1 class="<?php echo $this->item->backlink ? "backlink" : ""; ?>">
				<?php echo $this->item->backlink ? '<a class="backtomap" href="' . $this->item->backlink . '">' . JText::_('COM_FOCALPOINT_BACK_TO_MAP') . '</a>' : "";
				echo trim($this->item->title); ?>
			</h1>
		</div>

now I want to integrate the history.back function in place of the current

onclick="history.back(-1)"

so that the generated html looks something like

<a class="backtomap" href="#" onclick="history.back(-1)>' . JText::_('COM_FOCALPOINT_BACK_TO_MAP') . '</a>'

I tried to change the code here and there, but without the right knowledge it doesn't really work.

Can anybody help?

Thank you.


Solution

  • Just Change line

    '<a class="backtomap" href="' . $this->item->backlink . '">' . JText::_('COM_FOCALPOINT_BACK_TO_MAP') . '</a>' 
    

    with

    '<a class="backtomap" href="#" onclick="history.back(-1)" >' . JText::_('COM_FOCALPOINT_BACK_TO_MAP') . '</a>'