Liferay Portal has a JavaScript library that allows the creation of portletURLs inside your JavaScript code. Something like:
<input type="button" value="<liferay-ui:message key="cancel" />"
onclick="<portlet:namespace/>_back();"/>
<script type="text/javascript">
function <portlet:namespace/>_back() {
var backURL = Liferay.PortletURL.createRenderURL();
[...]

