javascript 事件绑定问题_javascript技巧
程序员文章站
2022-06-06 14:54:22
...
子页面HTML:
子页面JS:
function CreateIOC(text,value) {
var o = document.createElement("a");
o.id = value;
o.href = "#";
o.className = "c";
o.style.border = "2px solid red";
o.style.width = "250px";
o.style.height = "30px";
o.style.display = "block";
o.innerHTML = "
";
o.setAttribute("onclick", "iocClick()");
return o;
}
function iocClick() {
alert('ok');
}
function CheckedBox(box) {
window.parent.document.getElementById("kdks_panel").appendChild(CreateIOC('1','2'));
}
父级HTML:
复制代码 代码如下:
子页面JS:
复制代码 代码如下:
function CreateIOC(text,value) {
var o = document.createElement("a");
o.id = value;
o.href = "#";
o.className = "c";
o.style.border = "2px solid red";
o.style.width = "250px";
o.style.height = "30px";
o.style.display = "block";
o.innerHTML = "
" + text + " |
o.setAttribute("onclick", "iocClick()");
return o;
}
function iocClick() {
alert('ok');
}
function CheckedBox(box) {
window.parent.document.getElementById("kdks_panel").appendChild(CreateIOC('1','2'));
}
父级HTML:
复制代码 代码如下: