开发者

Data mining from iframes

I am interested in developing some javascript that resides as browser bookmark that can mine data from nested iframes and AJAX the data back to a remote server. A small collection such scripts would be used to coordinate player stats and attack strategy for a popular online game.

I am a novice javascript programmer and don't know if this is possible. My attempts thus far have failed, although I have authored other javascript code that works great in other applications.

Is it possible that I am violating the same-origin policy? Something is wrong. Code that should work gives me nothing.

Code such as this:

javascript:
 y=document.getElementsByTagName('iframe')[2];
 alert(y.src);

gives me the result one 开发者_如何学JAVAwould expect, but when I try to access what I think should be the innerHTML of the iframe, there is no result.

Any ideas?


It is very likely that you are violating the same-origin policy.

Recall that your scriptlet will be executing javascript in the domain of the currently loaded page. It also runs with the same restrictions imposed on that page, meaning that it is not allowed to access the content of an IFRAME if it contains a page in a different domain.

You are able to access the src property, because that exists on the tag in the page hosting the IFRAME but you won't be able to access much else, including the innerHTML.

Perhaps you could load that document (the one hosted in the iframe) into the browser, and then run your scriptlet against that?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜