Programmatically edit a Google document using JavaScript

What I'm trying to do is run JavaScript code that will enter text into a Google document. What I have done so far is to create an iframe element on my personal webpage, which includes Google Docs. At the moment, I want to use functions from the Google source code to enter text.

When I use the Chrome inspector with js beautifier, I find that if I listen to the keypress event, I get to the following code segment:

function dKa() {
   var a = eKa, b = TJa ? function(c) {
      return a.call(b.src, b.key, c)
   } : function(c) {
      c = a.call(b.src, b.key, c);
      if (!c)
      return c
   };
   return b
}

I tried calling the function when the page loaded with a simple event onload="function();"in a futile attempt to give a result, but nothing happened. Is there a way to do what I'm trying to do? I want to find the correct function to call so that I can write text to a document using this function. However, the code seems too confusing to do anything with help.

I know that to link to the Google Docs (iframe) code from the parent frame I need to do the following: document.getElementById("iframeID").contentWindow.theFunction() Am I really wrong in my execution? As far as I know, it’s not possible to edit a Google document using its API.

This is also my first post here, so if it is too vague let me know and hopefully I can clarify. Thanks in advance.

+5
3
+10

- , . DOM , .

0

Well, you cannot script on external sites, for example, in iFrames. Check out the same origin policy .


0
source

All Articles