繁体   English   中英

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

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

例如; 以下是 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>

我想获取我在 RoomDescription.html 页面上单击的任一 div 的值。 如何将信息作为 Room Type="Twin room 3" 和 price="8250" 从 HotelRooms 页面发送到 RoomDescription 页面。 此外如何在 RoomDescription.html 页面上获取参数值。 我意识到表单方法很方便,但直到设计了我的整个页面之后才学会它。

好吧,您可以使用 cookie 来这样做,但根据您帖子的上下文,这不是一个好主意,因为 cookie 可以由用户修改。 老实说,最好的选择是表单,几乎所有我能想到的在页面之间传输数据的方式,除了可以定位和修改之外。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM