0
function close_w() {
//close the window
}
function imgopen(image) {
var newWindow=window.open("", "_blank", "width=450, height=400");
var newButton=newWindow.document.createElement("button");
var textNode=newWindow.document.createTextNode("Close");
newButton.setAttribute("style", "text-align: center; width: 30%; height: 30px; margin-top: 10px; margin-left: 35%; border: none; color: #FFF; background-color: #DC143C");
newButton.setAttribute("onclick", "close_w()");
newWindow.document.newButton.appendChild(textNode); // Line Marker
newWindow.document.body.appendChild(newButton);
}
我想将一个按钮放在弹出窗口中,但将textNode附加到newButton不起作用,甚至按钮不显示。如果我删除标记的行,只显示按钮。关闭窗口并将文本节点追加到按钮
而且我还想让按钮被点击时弹出关闭,但我无法想象如何做到这一点。我可以使用什么函数来做close_W()?
这是一种任务:我不能在这里使用jQuery。
我对JS很虚弱。请帮忙!
我在这里看到一些答案,说文本节点并将其附加到按钮将工作。有没有办法使用这种方式?我知道innerhtml会工作,但只是好奇。 – keist99
我不知道如何能够使用文本节点并将其附加到按钮。向文本添加文本时,最好使用文本节点,例如'
',但我从未尝试在按钮上使用它。这可能是可能的,但我不知道你是如何做到的,但我仍然不会提出。 – CyanCoding