【问题标题】:How to open specific html in one frame from being in another frame?如何从另一个框架中打开一个框架中的特定html?
【发布时间】:2015-03-03 10:49:20
【问题描述】:

我在框架集中有一个框架如下:

<frameset rows="75%,25%">
    <frameset cols="20%,80%">
        <frame src="TreeGroup.jsp" name="left" id="f1"/>
        <frame src="DisplayMap.jsp"   name="top" id="f2"/>
    </frameset>
    <frame src="Tabs.jsp" name="bottom"/>
</frameset>  

在框架f1 中我有context menu 选项,所以如果我在框架f1 中单击AddVehicle 选项,它应该在框架2 (f2) 中打开新的jsp/html。所以在 Javascript 函数中我是这样做的,

 function addVehicle()
 {
   alert("In addVehicle");
//parent.top.location.href="http://localhost:8080/ITS_Server/Vehicle_Registration.jsp";
   top.frames['top'].location.href = "http://localhost:8080/ITS_Server/Vehicle_Registration.jsp?gname="+grp_name+"&did="+'<%=uid%>', "toolbar=yes, scrollbars=yes, resizable=yes, top=100,bottom=200, left=200, width=900, height=500";

 }

这里我面临的问题是,top.frames['top'].location.href 只有在我删除 URL 的所有参数并且它没有在 f2 框架中打开它在一个完整窗口中打开时才能正常工作。如何解决这个问题,请任何人帮助我。

【问题讨论】:

    标签: javascript html jsp frame frameset


    【解决方案1】:

    我认为您应该尝试设置帧 f2 的来源,而不是设置 location.href 属性。 如下所示:

    var frmap = document.getElementById("f2");
    frmap.src = "new url";
    

    【讨论】:

    • 告诉cannot set property src of null是一个错误
    • 我正在尝试从 TreeGroup.jsp 调用另一个页面,这里 id f2 在另一个文件中,其中只有我在上面提到的代码,那么 gwtElementById() 如何在 TreeGroup.jsp 页面中工作
    • 试试这个:top.window.frames["f2"]
    • 语法我不是很清楚,但是你需要使用dom层次访问frame f2,你也可以试试self.parent.document.getElementbyId("f2")。只需使用一些调试工具检查层次结构(在 .net 中我们可以使用监视窗口检查)并尝试使用相同的工具。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多