I would like to manipulate the HTML inside an iframe using jQuery.
(我想使用jQuery在iframe中操纵HTML。)
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:
(我认为我可以通过将jQuery函数的上下文设置为iframe的文档来做到这一点,例如:)
$(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. (一点检查显示出,除非等待iframe加载一会儿,否则frames['nameOfMyIframe']
中的变量是undefined
。)
However, when the iframe loads the variables are not accessible (I get permission denied
-type errors). (但是,在iframe加载时,变量不可访问(我收到permission denied
-类型错误)。)
Does anyone know of a work-around to this?
(有人知道解决方法吗?)
ask by rz. translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…