页面加载后,我无法执行从控制台访问属性的 Javascript 函数
我有一个页面加载一堆脚本来预填充下拉列表,并在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“预期对象”听起来像是
Popup
函数希望像Popup.call(somedomnode, args...)
那样被调用。 当从事件处理程序调用时,this
设置为调用处理程序的元素。 如果您只是尝试在没有this
等对象的情况下调用它,它可能会抱怨。否则,您想要调用的函数可能不在顶层范围内。 您并没有真正告诉我们这些函数是如何定义的或者事件处理程序是如何设置的,因此很难说更多问题可能出在哪里。
"Object expected" sounds like for example the
Popup
function wants to be called likePopup.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 asthis
, 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.