0

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...

  • in the same iframe
  • or to another webpage that appears in the same tab (which I could then embed the target document in). I don't really mind which, as long as a new tab isn't created every time someone clicks a link.

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?

1 Answers1

1

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.