jQuery:嵌套框架集中的访问框架 [英] jQuery: Access frame in nested frameset

查看:184
本文介绍了jQuery:嵌套框架集中的访问框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有嵌套框架集的文档。我需要访问其中一个名为sq_main的嵌套框架,并访问此框架内的内容。这是我的结构:

I have a document which has a nested frameset. I need to access one of the nested frames, named "sq_main", and access content inside this frame. Here is my structure:

<html>
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<frameset rows="28,*" frameborder="0" border="0">
  <frame src="/_admin/?SQ_BACKEND_PAGE=header" name="sq_header" scrolling="no" marginwidth="0" marginheight="0">
  <frameset cols="380,10,*" frameborder="0" border="0" id ="main_frameset">
    <frame src="/_admin/?SQ_BACKEND_PAGE=sidenav" name="sq_sidenav" scrolling="no" marginwidth="0" marginheight="0">
    <frame src="/_admin/?SQ_BACKEND_PAGE=resizer" name="sq_resizer" scrolling="no" marginwidth="0" marginheight="0">
    <frame src="/_admin?SQ_BACKEND_PAGE=main&assetid=43&sq_from_frontend=1" name="sq_main" marginwidth="0" marginheight="0" scrolling="yes">
  </frameset>
</frameset>
<noframes></noframes>
</html>

遗憾的是,我无法更改代码,这就是我需要使用jQuery访问它的原因。我曾尝试编写一个jQuery选择器来访问sq_main框架,但到目前为止没有运气:

Sadly, I can't change the code, that is why I need to access it with jQuery. I have tried to write a jQuery selector to access the "sq_main" frame, but no luck so far:

$('body', parent.frames[0].sq_main).prepend('<h1>TEST!!!!</h1>');

关于如何深入挖掘这个丑陋结构的想法? :)

Ideas on how to drill down into this ugly structure? :)

推荐答案

尝试一次导航一步。 IIRC, frames 数组仅适用于 iframes 。请尝试选择 frame [name ='sq_main']

Try to navigate one step at a time. IIRC, the frames array only works with iframes. Try the selector frame[name = 'sq_main'] instead.

Ronny Sherer

var frameDocument = $('frame[name="mainFrame"]', top.document)[0].contentDocument;
$(frameDocument).find('body').prepend('<h1>TEST!!!!</h1>');

这篇关于jQuery:嵌套框架集中的访问框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆