From app's iframe you will not be able to get hold of parent window url due to cross domain issue. The solution is to write a javascript that will be hosted in content editor webpart in parent window page. It will read parent window url and pass in that as query string parameter to app's iframe.
Find sample code below. I have passed the parent url's query string in to iframe urls query string. You can modify the same to your needs.
//Get all iframes(app parts) on page.
var iframeColl = document.getElementsByTagName('iframe');
for (var i = 0; i < iframeColl.length; i++) {
var thisIFrame = iframeColl[i]; // element
var src = thisIFrame.src;
if (src != null) {
//need to get the query string parts esp.find the 'redirect_uri' and APPEND some bits to it
var iframeUrl = src.substring(0, src.indexOf('?'));
var vars = getUrlVars(src);
var redirectUrl = vars["redirect_uri"];
var decodedRedirectUrl = unescape(redirectUrl);
var redirectParams = getUrlVars(decodedRedirectUrl);
// get the current url and the query string bit
var currentPageUrl = window.location.href;
var currentPageQueryString='';
// if there *IS* a query string then need to grab and pass on to the iFRAME
if (currentPageUrl.indexOf('?') != -1) {
//
// get the query string bit for current page
//
currentPageQueryString = currentPageUrl.substring(currentPageUrl.indexOf('?') + 1);
currentPageQueryString = currentPageQueryString + "&UserID=" + userId;
//Fix the query string
currentPageQueryString = escape(currentPageQueryString);
var clientID = vars["client_id"];
//add on the extra bit (for this page querystring)
redirectUrl = redirectUrl + "%26" + currentPageQueryString;
//piece back together and update the iframe
var newUrl = iframeUrl + "?redirect_uri=" + redirectUrl + "&client_id=" + clientID;
//update the SRC in the IFRAME
thisIFrame.src = newUrl;
}
}
}