如何在不使用表单和输入标签的情况下将数据从一个HTML页面传输到另一个HTML页面

how to transfer data from one html page to another without using forms and input tags

本文关键字:HTML 一个 另一个 页面 传输 数据 表单 情况下 标签 输入      更新时间:2023-09-26

例如;以下是HotelRooms.html

中酒店房间的简短摘要的html片段
<div class="Room1"  onclick="window.location.href='RoomDescription.html'">
        <div class="roomInfoaltered">
          Luxury room 1 <br>
          <span style="font-size:18px; font-family:Tillana">PKR 4,250</span>
        </div>
      </div>
<div class="Room2" onclick="window.location.href='RoomDescription.html'">
        <div class="roomInfoaltered">
          Twin room 3 <br>
          <span style="font-size:18px; font-family:Tillana">PKR 8,250</span>
        </div>
      </div>

我想获得任何div的值,我点击RoomDescription.html页面。我如何发送信息作为房间类型="双人房3"和价格="8250"从HotelRooms页面到RoomDescription页面。此外,如何在RoomDescription.html页面上获取参数值。我意识到表单方法很方便,但是直到我设计了整个页面之后我才学会使用它。

好吧,你可以使用cookie来做到这一点,但根据你的文章的上下文,这不是一个好主意,因为cookie可以被用户修改。最好的选择是表单,实际上我能想到的所有在页面之间传输数据的方法都是可以被定位和修改的。