Search code examples
htmlgoogle-drive-apigoogle-docsgoogle-drive-shared-drive

after I Embedded a Google Drive folder on my web page is there any way to get number of files in to my web page?


Exaple:

<iframe src="https://drive.google.com/embeddedfolderview?id=FOLDER-ID#grid" style="width:100%; height:600px; border:0;"></iframe>

I want to show number of files in side my google drive folders automatic in HTML page

Like

<p> {number of files} Files</p>

output should be something like this

10 Files 

or

20 Files

so I want that number change whenever I add a new file to that folder.


Solution

  • Short answer

    You can't.

    Long answer

    You can access an element inside an iframe of your page with javascript something like this:

     window.frames['frameid'].contentDocument.getElementById('elementid')
    

    however, for security reasons, the "same origin policy" https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy applies. So, this method will not work in your case, because the domain in one origin the one of the iframe (drive.google.com) is not the same as the domain a different origin, your page.