javascript:访问不同框架中的对象?

javascript:访问不同框架中的对象?

问题描述:

如果我在1页上有2帧的框架集,JS是否有办法从相反的框架访问元素?

if I have 2 frames of a frameset on 1 page, is there a way for JS to access elements from the opposite frame?

谢谢!

是的,但前提是两个帧上的页面都在同一个域上。您可以执行 document.getElementById(frame_id)。contentWindow.document ...但是如果页面位于不同的域中,您将获得异常。

PS。您可以阅读更多此处

Yes, but only if pages on both frames is on the same domain. You can do document.getElementById( "frame_id").contentWindow.document... But still if pages are on different domain you will get an exception.
PS. You can read more here