Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Get Parent URL in IFrame:iframe and its parent are in Different domain

I am struggling to get parenet URL inside my iframe (ie the url showing in browser). My parent site is gslb13.aaa.com .Inside there is an iframe in which i am loading my site test.elasticbeanstalk.com (notice both are in different domain) Onclicking smile link in gslb13.aaa.com. It will load test.elasticbeanstalk.com inside iframe.

To get the parent url I tried with

var url = (window.location != window.parent.location) ? document.referrer: document.location;
alert(url);

I am getting the parent URL in index page of test.elasticbeanstalk.com (on load). then:

1) I clicked "Add" buttons in the test.elasticbeanstalk.com to go to next view

2) Repeated the same code in add.jspx to get the same parent URL

But unfortunately I am getting the URL of test.elasticbeanstalk.com(Not Parent URL:gslb13.aaa.com )

Can Any one suggest me a way to handle this?

like image 680
Charlie Avatar asked Mar 21 '23 12:03

Charlie


1 Answers

use

document.referrer;

Refer This

like image 108
Milind Anantwar Avatar answered Apr 25 '23 17:04

Milind Anantwar