0

I have a website for my gadget files and I’ve made a windows 7 gadget with an iframe to connect to it. The problem that I’m having is that I need to somehow send a message using javascript. The best option for me was to try parent.loadPage(‘page’) and send that from the iframe (running on a different domain) to the function of the windows 7 gadget however it does not work. Does anyone have any ideas on this it would be greatly appreciated.

Just to clarify The iframe is connecting to a website e.g. (www.example.com/gadget/page.php) The page contains a link using onClick parent.loadPage

Addramyr
  • 254
  • 4
  • 11
  • I guess you're probably being blocked by the browser from running cross site scripting (as a gadget is effectively working as a browser), although that is a total guess – freefaller Jun 10 '12 at 15:24
  • I know that some tools (like phonegap) doesn't allow you to use iframes at all, not only in case of cross-site scripting. Why not using ajax-request? – Dmitry Laptev Jun 10 '12 at 16:26
  • Yes, actually in [this question](http://stackoverflow.com/questions/4884676/accessing-parent-dom-function-from-within-an-iframe-embedded-in-windows-7-gadget) they stated that communication between the framed page and the hosting gadget is be blocked. You'd probably better find another way of interacting. And again, ajax should work fine. – Dmitry Laptev Jun 10 '12 at 17:36

1 Answers1

0

In light of no direct answers, let me summarise...

The short answer is "no, you can't".

The longer answer is that the gadget is effectively a browser, and will therefore block any javascript communication between the iFrame and the parent due to cross-site scripting (XSS) protection.

Instead (assuming you have control over the content you're trying to display in the iFrame) you should look at bringing back the information you want to display via AJAX, and displaying it directly into the gadget.

Community
  • 1
  • 1
freefaller
  • 19,368
  • 7
  • 57
  • 87