簡體   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