Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
新框架中的Javascript Url问题_Javascript_Html - Fatal编程技术网

新框架中的Javascript Url问题

新框架中的Javascript Url问题,javascript,html,Javascript,Html,我有一个JavaScript问题。我使用它在新框架中打开HTML网页,并具有以下功能: function openBranch(url) { if (url == "Ping") { top.folderFrame.location = "Ping.html" } else if (url == "Logout") { top.top.location = "Logout.html" } } HTML用法: <a href='javascript:openBr

我有一个JavaScript问题。我使用它在新框架中打开HTML网页,并具有以下功能:

function openBranch(url) {
  if (url == "Ping") {
    top.folderFrame.location = "Ping.html"
  } else if (url == "Logout") {
    top.top.location = "Logout.html"
  }
}
HTML用法:

<a href='javascript:openBranch("Ping")'>Ping</a>


一旦处理了我的
Ping.html
页面(使用Post请求),我就无法在侧边菜单栏中打开另一个网页。“我的侧边”菜单栏无法打开新页面,也无法处理任何请求。

该函数的参数似乎更改了文档的来源。如果您只想更改源代码,为什么不这样做:

<iframe src="test1.html" id="top"></iframe>
<a href="#" onclick="change(1)">change to 1</a>
<a href="#" onclick="change(2)">change to 2</a>


    <script>

        function change(val) {

            if (val === 1) {
                document.getElementById("top").src = "test1.html";
            } else {
                document.getElementById("top").src = "test2.html";
            }

        }

    </script>

功能更改(val){
如果(val==1){
document.getElementById(“top”).src=“test1.html”;
}否则{
document.getElementById(“top”).src=“test2.html”;
}
}

为什么需要一个新框架?