Thomas Tiersen
Thomas Tiersen

Reputation: 1

How can I force google docs embedded in iframes to open their links in the same window?

I'm currently making an educational resource with google drive.

I've currently got the "Publish to web" version of the google documents embedded in an iframe in an html document using

<iframe src="https://docs.google.com/document/d/e/2PACX-1vSaUZ2XolOoqc0M12v-VNTTMcz3dIAnAOO9gaCyifoAXhlWiKz114M2QYoQ5d-dNBEsgWDcXahKNMSD/pub" frameborder="0"></iframe>

I've inserted hyperlinks (using the built in hyperlink function) in the google docs, to link to other (published) google docs eg:

https://docs.google.com/document/d/1XnTTbjedXkL3OfeELMwzabeeL4FjnOjarmmWbKb97EY/pub

At the moment, all clicked links are opened in a new tab. This happens whether I link to other google docs, or to external sites. Naturally, this is quite frustrating for navigating the site.

I'd like to have them open either...

I see from similar questions posted that in the past people seem to have had the opposite problem - trying to force the links to open in new tabs, so perhaps something has changed with the way links are handled?

Upvotes: 0

Views: 1004

Answers (1)

Daniel Ternyak
Daniel Ternyak

Reputation: 113

For onlookers, the reason for the varying behavior is due to the query parameter that either is or isn't present as the src value:

You can see that the OP does not have ?embedded=true at the end (after /pub).

<iframe src="https://docs.google.com/document/d/e/2PACX-1vSaUZ2XolOoqc0M12v-VNTTMcz3dIAnAOO9gaCyifoAXhlWiKz114M2QYoQ5d-dNBEsgWDcXahKNMSD/pub" frameborder="0"></iframe>

Google doesn't document the differing functionality very well, but a URL like

https://docs.google.com/document/d/e/2PACX-1vSaUZ2XolOoqc0M12v-VNTTMcz3dIAnAOO9gaCyifoAXhlWiKz114M2QYoQ5d-dNBEsgWDcXahKNMSD/pub?embedded=true

will provide the desired behavior of keeping links opening in-iframe.

Upvotes: 1

Related Questions