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

时间:2022-10-04 01:22:00

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.

页面加载后,我在脚本控制台中打开页面,我无法做任何事情。一切都是null,功能不存在。

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.

如果我尝试从脚本控制台调用它,我会得到Object Expected错误,就好像它甚至不存在一样。但是如果我点击按钮,方法就会向上发射。我无法修改此代码,因此我必须完成此功能。

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?

任何人都知道发生了什么,有没有办法调用这些功能?

1 个解决方案

#1


"Object expected" sounds like for example the Popup function wants to be called like Popup.call(somedomnode, args...). When called from an event handler, this is set to the element the handler is called on. If you just try to call it without some object as this, it might complain.

“预期的对象”听起来像是弹出函数想要像Popup.call(somedomnode,args ...)一样被调用。从事件处理程序调用时,将其设置为调用处理程序的元素。如果您只是尝试在没有某个对象的情况下调用它,它可能会抱怨。

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.

否则,您要调用的函数可能不在*范围内。您并没有真正告诉我们如何定义这些函数或如何设置事件处理程序,因此很难说出问题可能出现的地方。

#1


"Object expected" sounds like for example the Popup function wants to be called like Popup.call(somedomnode, args...). When called from an event handler, this is set to the element the handler is called on. If you just try to call it without some object as this, it might complain.

“预期的对象”听起来像是弹出函数想要像Popup.call(somedomnode,args ...)一样被调用。从事件处理程序调用时,将其设置为调用处理程序的元素。如果您只是尝试在没有某个对象的情况下调用它,它可能会抱怨。

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.

否则,您要调用的函数可能不在*范围内。您并没有真正告诉我们如何定义这些函数或如何设置事件处理程序,因此很难说出问题可能出现的地方。