有没有办法在 javascript 控制台中将上下文更改为 iframe? [英] Is there a way to change context to iframe in javascript console?

查看:28
本文介绍了有没有办法在 javascript 控制台中将上下文更改为 iframe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改在 webkit 开发人员工具/firebug 控制台中执行的 javascript 的上下文,以执行其代码,就像它从页面上的 iframe 内部运行一样.

我知道我可以通过在单独页面上的 iframe 中打开页面来实现这一点,但我想在它与父框架交互的地方运行代码.

解决方案

Chrome 15 允许您更改控制台的范围.在控制台底部,在清除控制台按钮旁边,有一个菜单,上面写着 ,它将提供可用帧的列表:

Firefox 有一个:

var frame = document.getElementById("frame1").contentWindow;cd(帧);

I would like to change the context of the javascript executed in the webkit developer tool/firebug console to execute its code like it is running from inside an iframe on the page.

I know I could do this by opening the page in the iframe on a separate page, but I want to run code where it interacts with the parent frame.

解决方案

Chrome 15 allows you to change the scope of the console. On the bottom of the console, next to the clear console button, there is a menu that says <top frame> which will give a list of available frames:

Firefox has a similar feature currently in development:


You can also navigate across frames using the command line:

var frame = document.getElementById("frame1").contentWindow;
cd(frame);

这篇关于有没有办法在 javascript 控制台中将上下文更改为 iframe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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