简体   繁体   English

页面加载后,我无法执行从控制台访问属性的Javascript函数

[英]After page loads I can't execute Javascript functions that access properties from console

I have a page that loads a bunch of scripts to prepopulate dropdowns and has scripts within the html onclick events and etc. 我有一个页面,该页面加载了一堆脚本以预填充下拉列表,并且在html onclick事件等中包含脚本。

After the page loads and I open the page in the script console I can't do anything. 页面加载后,我在脚本控制台中打开页面,我什么也不能做。 everything is null and functions non-existent. 一切为空,功能不存在。

For example there is an onClick function onclick="Popup('Seattle');" 例如,有一个onClick函数onclick="Popup('Seattle');" .

If I try to invoke that from the script console I get Object Expected error like it doesn't even exist. 如果尝试从脚本控制台调用该命令,则会收到“对象预期”错误,甚至根本不存在。 But if I click the button the method fires right up. 但是,如果我单击按钮,该方法将立即触发。 I can't modify this code so it's important that I get this functions going. 我无法修改此代码,因此使此功能正常运行很重要。

While I'm stepping through the code and have the script paused I have access to everything but as soon as it's finished it's back to nothing at all. 当我单步执行代码并暂停脚本时,我可以访问所有内容,但是一旦完成,它就什么都没有了。

Anyone know what's going on and is there a way to invoke these functions? 任何人都知道发生了什么,有没有办法调用这些功能?

"Object expected" sounds like for example the Popup function wants to be called like Popup.call(somedomnode, args...) . “预期对象”的声音听起来像例如Popup函数想要像Popup.call(somedomnode, args...)这样Popup.call(somedomnode, args...) When called from an event handler, this is set to the element the handler is called on. 当从事件处理程序调用时, this设置为调用处理程序的元素。 If you just try to call it without some object as this , it might complain. 如果您只是尝试不带this对象而调用它,则可能会抱怨。

Otherwise probably the functions you want to call are not in scope at top-level. 否则,您想调用的函数可能不在顶级范围内。 You don't really tell us how these functions are defined or how the event handlers get set up, so it's hard to say more where the problem might be. 您并没有真正告诉我们这些函数的定义方式或事件处理程序的设置方式,因此很难说出问题所在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM