我正在尝试通过 JavaScript 打开一个窗口,但它只是不断刷新,什么也不做。起初我以为这只是 Google Chrome,但在 Firefox 和 IE 中也是如此。不确定我的问题是什么。 JSFiddle 说了一些关于“POST”的内容,但我不确定。有建议吗?
function romantic()
{
document.body.bgColor = "pink";
document.body.style.color = "red";
document.images[1].src = "rom_main.jpg";
// Searched online to find a script to override some styles.
// For loop with adding styles to each anchor didn't work for some reason. Kept being overriden somehow.
var styleElement = document.createElement("style");
styleElement.type = "text/css";
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = "a { color: red }";
} else {
styleElement.appendChild(document.createTextNode("a { color: red; }"));
}
document.getElementsByTagName("head")[0].appendChild(styleElement);
}
function adventure()
{
document.body.bgColor = "#CDAA7D";
document.body.style.color = "#5C3317";
document.images[1].src = "adv_main.jpg";
var styleElement = document.createElement("style");
styleElement.type = "text/css";
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = "a { color: #5C4033 }";
} else {
styleElement.appendChild(document.createTextNode("a { color: #5C4033; }"));
}
document.getElementsByTagName("head")[0].appendChild(styleElement);
}
function relax()
{
document.body.bgColor = "#B2DFEE";
document.body.style.color = "#00688B";
document.images[1].src = "rel_main.jpg";
var styleElement = document.createElement("style");
styleElement.type = "text/css";
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = "a { color: #000080 }";
} else {
styleElement.appendChild(document.createTextNode("a { color: #000080; }"));
}
document.getElementsByTagName("head")[0].appendChild(styleElement);
}
function family()
{
document.body.bgColor = "#F0E68C";
document.body.style.color = "#FFA54F";
document.images[1].src = "fam_main.jpg";
var styleElement = document.createElement("style");
styleElement.type = "text/css";
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = "a { color: #6B4226 }";
} else {
styleElement.appendChild(document.createTextNode("a { color: #6B4226; }"));
}
document.getElementsByTagName("head")[0].appendChild(styleElement);
}
function open()
{
mywindow = window.open("http://www.javascript-coder.com", "mywindow", "location=1,status=1,scrollbars=1, width=100,height=100");
mywindow.moveTo(0, 0);
}
最佳答案
伙计将你的函数名称更改为 winopen:open 是一个关键字我确定:
关于Javascript弹出框不会弹出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7763962/