Javascript: 访问 iframe 的内容

I would like to manipulate the HTML inside an iframe using jQuery.

I thought I'd be able to do this by setting the context of the jQuery function to be the document of the iframe, something like:

$(function(){ //document ready
    $('some selector', frames['nameOfMyIframe'].document).doStuff()
});

However this doesn't seem to work. A bit of inspection shows me that the variables in frames['nameOfMyIframe'] are undefined unless I wait a while for the iframe to load. However, when the iframe loads the variables are not accessible (I get permission denied-type errors).

Does anyone know of a work-around to this?

转载于:https://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe

查看全部
csdnceshi69
YaoRaoLov
2008/12/13 07:20
  • iframe
  • javascript
  • same-origin-policy
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

0个回复