简体   繁体   English

子级请求父级窗口元素的OnChange请求

[英]Child Requesting OnChange request of Parent Window element

So I have this in my child iframe has this code running with in it. 因此,我的孩子在iframe中拥有此代码,并在其中运行了此代码。

window.parent.document.getElementById("cs_0000").onchange = function () {
    alert('Worked');
};

For what ever reason it's not working. 无论出于什么原因,它都不起作用。

I can run this code: 我可以运行以下代码:

window.parent.document.getElementById("cs_0000").value;

and it will return the value of that element but the on change event doesn't work. 并且它将返回该元素的值,但是on change事件不起作用。

The result was because the hidden fields don't trigger change events. 结果是因为隐藏字段不会触发更改事件。

So after using: 因此,使用后:

.trigger("change");

I was able to catch the event using: 我能够使用以下方法捕获事件:

window.parent.jQuery('#something').on('change', function(){
    // Put stuff here
});

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

相关问题 使用 React 单击父元素触发子 onchange 处理程序 - Trigger child onchange handler from click on parent element with React 为什么从子窗口调用父窗口文本框的OnChange事件不起作用 - Why Does OnChange Event of Parent window textbox when called from child window not working 如何检查请求来自子窗口的父窗口 - how to check request come from parent window for child window 在子窗口中使用数组元素使用getElementById更改父窗口中的图像 - Using array element in child window to change image in parent window with getElementById 如何在反应中将多个onChange表单数据从子元素传递到父元素 - How to pass multiple onChange form data from child to parent element in react onChange of <select>子组件中的元素未在React中重新呈现父状态,警告:未安装的组件 - onChange of <select> element in child component not re-rendering the parent state in React, Warning: unmounted component 调整子div元素的大小以适合窗口调整大小的父div - Resize child div element to fit in parent div on window resize 从父组件传递 onChange 覆盖子组件的 onChange - React - Passing onChange from parent overides onChange of the child component - React 父 onChange 将子属性设置为 true - Parent onChange sets child property to true 在 React 中将 onChange 事件从子级传递给父级 - Passing onChange event from child to parent in React
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM