javascript语法问题,一个文件中的多个函数

时间:2015-05-06 06:26:14

标签: javascript html

这里完全没有问题,我有这个JS代码,其中只使用一个功能完美,但添加第二个使它停止工作。

function PSN() {
    var myWindow = window.open("http://sintarjetas.com.ar/forms/psn.html", "Fran", "width=380, height=400");
}
function BLIZ() {
    var myWindow = window.open("http://sintarjetas.com.ar/forms/bliz.html", "Fran", "width=380, height=400");
}
function XLA() {
    var myWindow = window.open("http://sintarjetas.com.ar/forms/xla.html", "Fran", "width=380, height=400");
}
function STEAM() {
    var myWindow = window.open("http://sintarjetas.com.ar/forms/steam.html", "Fran", "width=380, height=400");
}

当只有一个函数写入时,PSN按钮工作正常,但是当我放置2个或更多时,所有链接都停止工作。 是因为这个文件的语法?或者我错过了什么?

1 个答案:

答案 0 :(得分:1)

你不需要多个功能来打开弹出窗口,你可以创建单个函数并传递url作为参数

function popUp(url) {
   return window.open(url, "Fran", "width=380, height=400");
}

注意:将您的功能块放在页面的<header>中,然后尝试。这是working fiddle

更新:由于所有窗口名称都相同Fran,因此您需要先关闭打开的窗口,然后再打开其他窗口。目前,它将在之前打开的窗口中打开网址。

相关问题