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

发布于 2024-07-25 09:59:51 字数 375 浏览 4 评论 0原文

我有一个页面加载一堆脚本来预填充下拉列表,并在 html onclick 事件等中包含脚本。

页面加载后,我在脚本控制台中打开页面,我无法执行任何操作。 一切都是空的,功能也不存在。

例如,有一个 onClick 函数 onclick="Popup('Seattle');"

如果我尝试从脚本控制台调用它,我会收到 Object Expected 错误,就像它甚至不存在一样。 但如果我单击按钮,该方法就会立即启动。 我无法修改此代码,因此让此功能正常运行非常重要。

当我单步执行代码并暂停脚本时,我可以访问所有内容,但一旦完成,它就什么也没有了。

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

I have a page that loads a bunch of scripts to prepopulate dropdowns and has scripts within the html onclick events and etc.

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');".

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妥活 2024-08-01 09:59:51

“预期对象”听起来像是 Popup 函数希望像 Popup.call(somedomnode, args...) 那样被调用。 当从事件处理程序调用时,this 设置为调用处理程序的元素。 如果您只是尝试在没有 this 等对象的情况下调用它,它可能会抱怨。

否则,您想要调用的函数可能不在顶层范围内。 您并没有真正告诉我们这些函数是如何定义的或者事件处理程序是如何设置的,因此很难说更多问题可能出在哪里。

"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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文