更新:它仍然无法正常工作。链接是可点击的,但它们也没有到达预期的位置。例如,当您从第 1 帧单击联系信息时,它应该在第 3 帧中打开它。从 Fame 1 中,当您单击“营业时间”时,它应该在第 3 帧中显示营业时间。
更新 2:添加 # 符号后...当我单击联系信息时...它会在 FRAME 3 中显示 FRAME 1 并删除 FRAME 3 中的内容。这不是我假设要做。
所以..我有四个框架。这些框架的代码如下所示。所以它将在一页中显示四个不同的框架。还显示了该图片。
<!DOCTYPE html>
<html>
<head>
<title> A4 - HTML Frames - Jainamkumar Patel </title>
</head>
<frameset cols = "20%,50%">
<frame src = "frame1.html">
<frameset rows = "30%,30%">
<frame src = "frame2.html">
<frameset cols = "25%,25%">
<frame src = "frame3.html" name = "frame1">
<frame src = " ">
</frameset>
</frameset>
</frameset>
</html>
现在这就是我想做的:
Pane 2 包含指向联系信息、服务、营业时间和产品说明的超链接。至少有 3 个指向产品描述的链接。
浏览器窗口的第 3 Pane 包含描述联系信息、服务、营业时间的页面,相应的链接指向这些页面。
第 1 帧代码:
<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" href = "HTML_Style_Sheets.css">
</head>
<body>
<h1> CRC Software Solutions </h1>
<h2> About Us </h2>
<p><a href = "#frame3.html" target = "frame1"> Contact Information </a></p>
<p><a href = "#frame3.html" target = "frame1"> Services </a></p>
<p><a href = "#frame3.html" target = "frame1"> Hours of Operation </a></p>
<p><a href = "#frame3.html" target = "frame1"> Product Descriptions </a></p>
<ol>
<li> Product 1 Description </li>
<br>
<li> Product 2 Description </li>
<br>
<li> Product 3 Description </li>
</ol>
</body>
</html>
第 3 帧代码:
<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" href = "HTML_Style_Sheets.css">
</head>
<body>
<h1> Contact Information </h1>
<p> 4837 Blind Bay Road <br>
Celista, BC V0E 1L0 <br>
250-955-5462 <br>
</p>
<p> For any difficulties or questions you might have regarding out website and services please contact our Support Team. </p>
<p> support@crctech.com </p>
<h1> Hours of Operation </h1>
</body>
</html>
所以我想做的是将联系信息链接到框架 3。因此,当您单击 Frame 1 中的 CONTACT INFORMATION 时,它应该会在 Frame 3 中打开它。服务也一样。在第 1 帧中单击服务后......它应该在第 3 帧中显示服务。(我仍然需要做服务部分,但我已经完成了联系信息部分)。
问题: 当我运行它时..并单击联系信息..它会在新选项卡中打开 FRAME3,这不是我必须做的。
是的,我知道它很大,但请帮我解决这个问题。
谢谢。
最佳答案
在<frame>
<frameset>
内的标签标记你必须使用属性 name
对于框架,不是 ID
, 像这样
<frameset cols = "20%,50%">
<frame src = "frame1.html" name = "frame1">
<frameset rows = "30%,30%">
<frame src = "frame2.html" name = "frame2">
<frameset cols = "25%,25%">
<frame src = "frame3.html" name = "frame3">
<frame src = " ">
那么您的链接(在 frame1 内)应该是这样的:
<a href = "frame3.html" target = "frame3">
(附言:如果您需要 ID,可以同时使用姓名和 ID)
关于html - 如何在 HTML 中打开指向另一个框架的链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40565672/