如何在 HTML 中打开指向另一个框架的链接?

J p*_*tel 5 html anchor href frame target

更新:它仍然无法正常工作。链接是可点击的,但它们也没有采用它的假设。例如,从第 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>
Run Code Online (Sandbox Code Playgroud)

现在这就是我想要做的:

窗格 2 包含指向联系信息、服务、营业时间、产品说明的超链接。至少有 3 个链接到产品说明。
浏览器窗口的窗格 3 包含描述联系信息、服务、营业时间以及相应链接所指的页面。

第一帧代码:

<!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> 
Run Code Online (Sandbox Code Playgroud)

第 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>
Run Code Online (Sandbox Code Playgroud)

所以我想做的是将联系信息链接到第 3 帧。因此,当您单击 Frame 1 中的 CONTACT INFORMATION 时,它应该会在 Frame 3 中打开该信息。服务也是如此。一旦在框架 1 中单击服务...它应该在框架 3 中显示服务。(我仍然需要做服务部分,但我已经完成了联系信息部分)。

问题:当我运行它时..并单击联系信息..它会在新选项卡中打开 FRAME3,这不是我必须做的。

是的,我知道它很大,但请帮我解决这个问题。

谢谢你。

Joh*_*nes 3

在标签<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 = " ">
Run Code Online (Sandbox Code Playgroud)

那么你的链接(在frame1内)应该是这样的:

<a href = "frame3.html" target = "frame3">
Run Code Online (Sandbox Code Playgroud)

(PS:如果需要ID,可以同时使用姓名ID)