Programmatically edit a Google doc with JavaScript

我的梦境 提交于 2019-12-05 10:35:07

As others have noted the same-origin policy will prevent the approach you're taking from working, and trying to reverse-engineer it is folly anyway as the implementation could change at any time (or even be different for different users as Google rolls out updates).

However, Google has an API for this exact thing called Google Apps Script. Most of the tutorials are geared toward spreadsheets, but there is documentation for DocumentApp, DocsList, Document, etc. You may have to rethink your approach a bit but you should still be able to accomplish your goals.

As far as I know due to cross-site security restrictions this is not possible. You can only access the DOM of the page, if the source domain is the same.

Well, you can't script on outside sites like those in iFrames. Check the same origin policy.


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!