I'm implementing a "widget" that will be included on article/story pages of a 3rd-party website. This widget lives in an <iframe> hosted on our domain. It needs to gather text from the articles of its parent page (the 3rd-party website), which it then uses to make a variety of API calls to services that return related content, which is then displayed in our <iframe> widget.
I can't access the DOM of the parent page due to cross-domain security restrictions, and therein lies the problem. I can place just about any code that I need to on the parent page (e.g., some JavaScript that parses out the content that I need), and the <iframe> is also totally under my control, but I'm not sure how to get the content from the host page into my <iframe> since they're hosted on different domains. Security is very important and I'd like to find a method that doesn't compromise that in any way.
My initial thought was to pass the page content from the parent page into my <iframe src=""> attribute using a query parameter:
<iframe src="http://www.mydomain.com/widget.html?page_content=This is some page content."></iframe>
I could use a <script> on the parent page to gather the text, then document.write an <iframe> that uses the string holding my text to create a dynamic "page_content" query parameter. The page_content parameter would then be available to my <iframe> page in document.href.
However, I need to gather 8 KB of text from the parent page, and my understanding is that GET requests have a 1 KB limit - is this true? If not, or if I can configure that limit on my server, problem likely solved.
If that is going to be a limitation, how else could I get creative and pass this text into my widget? This needs be a very scalable solution, as the parent website gets tens of millions of page views monthly. I also don't want to impact the performance of the parent page in a significant way.
I have jQuery available in my widget, but can't rely on anything but plain JavaScript in the parent page.