简体   繁体   中英

Accessing the url of a remote window in Javascript

I open a new window to a Google docs presentation using the method window.open:

NewWindow = window.open("https://docs.google.com/presentation/d/1Qs9......");

I want to retrieve that url in order to know of it has changed (each slide of the presentation has a different url and i want to see if the user changed slides), using NewWindow.location.href

All i get is an undefined value. I can change href though

NewWindow.location.href ="http://www.google.com"; //works

I've read that if you are not in the same domain, you are not allowed to access the href or any other properties on the remote window.

Isn't there any other way to do it?

Thanks in advance.

There is a workaround but not in JavaScript.

The standard solution is to map the documents into your own domain using a proxy server that runs hidden under some URL of your own domain.

That way, you can access the documents via https://your.doma.in/google/presentation/...

A word of warning: If you make a mistake with configuring the proxy, crackers can abuse it to do nasty things (like trying to hack Google or send spam; the police will come knocking on your door).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM