访问文档从未完全加载的框架中的内容
我有一个不寻常的设置。首先,我有一个带有框架的页面
<html>
<head>
<title>My Chat</title>
</head>
<frameset id="resize" rows="*,135">
<frame name="Main" src="/chat/stream.pl">
<frame name="Comm" src="/chat/realm.pl">
</frameset>
</html>
主框架包含不断从服务器流式传输的内容。问题是浏览器将此视为页面从未完成加载,并且不会发生超时。页面上,有这样的内容。
<table class="PSTPRI" cellspacing="3" cellpadding="2">
<tr>
<td>
<IMG SRC="http://mysite.com/myimage.jpg" HEIGHT="470" WIDTH="550" ALIGN="left" BORDER="0">
<!-HEAD--> lots of text for the post header <!-POST-->
<p><span style="font-size: 11px; color: #FFFFFF; font-family: Verdana;">the post text<BR></span></p>
</td>
</tr>
<!-- ...more content here, each post is a new TR -->
</table>
我希望能够将实时事件绑定到此内容中的图像。警告 - 我将其作为 chrome 扩展,将其分配给包含框架集的页面。该脚本有效,我只需要能够将事件附加到图像即可。现在,这是我想要附加的示例事件。
$('table.PSTPRI td img').live('click', function () {
alert('test');
});
但问题是 1)我不知道如何在正确的上下文中选择图像,2)我需要选择器假设文档从未加载过,即使显示了对象在屏幕上。
I have an unusual setup. First off, I have a page with frames
<html>
<head>
<title>My Chat</title>
</head>
<frameset id="resize" rows="*,135">
<frame name="Main" src="/chat/stream.pl">
<frame name="Comm" src="/chat/realm.pl">
</frameset>
</html>
The main frame has content that is continually streaming from the server. The problem is that the browser treats this as if the page is never done loading, and no timeout occurs. On the page, there is content like this.
<table class="PSTPRI" cellspacing="3" cellpadding="2">
<tr>
<td>
<IMG SRC="http://mysite.com/myimage.jpg" HEIGHT="470" WIDTH="550" ALIGN="left" BORDER="0">
<!-HEAD--> lots of text for the post header <!-POST-->
<p><span style="font-size: 11px; color: #FFFFFF; font-family: Verdana;">the post text<BR></span></p>
</td>
</tr>
<!-- ...more content here, each post is a new TR -->
</table>
I want to be able to bind a live event to the image in this content. The caveat - I am making this as a chrome extension that I am assigning to the page containing the frameset. The script works, I just need to be able to attach an event to the image. for now, here is my sample event that I want to attach.
$('table.PSTPRI td img').live('click', function () {
alert('test');
});
The problem though, is that 1) I don't know how to select the image in the correct context, and 2) I need the selector to work on the assumption that the document isn't ever loaded, even though the objects are shown on the screen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,您的问题中缺少一些细节,所以如果这不是您寻求的答案,请原谅我。
我相信您正在尝试在“带框架的页面”中注入一些脚本。
如果这是正确的,您所要做的就是在 content_scripts 部分下的 manifest.json 中设置两个属性,如下所示:
参考:
http://code.google.com/chrome/extensions/content_scripts.html
Well, there are some details missing in your question, so forgive me if this is not the answer you seek.
I believe that you are trying to inject some scripts in your "page with frames".
If that's right, all you have to do is set two properties in manifest.json under content_scripts section as follows:
References:
http://code.google.com/chrome/extensions/content_scripts.html