【问题标题】:how to transfer data from one html page to another without using forms and input tags如何在不使用表单和输入标签的情况下将数据从一个 html 页面传输到另一个页面
【发布时间】:2017-02-25 17:51:17
【问题描述】:

例如;以下是 HotelRooms.html 中酒店房间简短摘要的 html sn-p

<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 页面上的参数值。我意识到表单方法很方便,但是在设计了整个页面之后直到现在才学会它。

【问题讨论】:

  • 添加到url -> RoomDescription.html?room=3&amp;price=300
  • @adeneo 以及如何在下一页获取这些参数。通过javascript?

标签: javascript java jquery html css


【解决方案1】:

好吧,您可以使用 cookie 来执行此操作,但根据您帖子的上下文,这不是一个好主意,因为 cookie 可以由用户修改。最好的选择是诚实的表单,实际上我能想到的在页面之间传输数据的所有方式都可以有针对性和修改。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多