MatDepInfo
MatDepInfo

Reputation: 337

Get the url from frame redirection

I did a frame redirection to redirect subdomain.domain1.com to domain2.com. It works well ie I got "subdomain.domain1.com" in the address bar and the domain2.com is well displayed. However, I try to get the url in js code.

console.log(window.location.href);

This line show me "domain2.com" but it would be "subdomain.domain1.com". How to get that ?

Upvotes: 0

Views: 191

Answers (1)

Quentin
Quentin

Reputation: 943759

window refers to the current page.

If you want the URL of the parent frame then you would need to go to window.parent.

At that point you'll run into a cross-origin error. If you controlled the parent then you could use postMessage to pass the data through.

Since you are using a frame redirection, that seems unlikely though. Generally this is one of many limitations with frame based redirection that mean you should generally avoid that approach in the first place.

Upvotes: 1

Related Questions