doz95923 2012-09-07 08:57
浏览 3
已采纳

改变浏览器PHP中的后退行为

In my PHP site, when a user adds something to their cart I trigger a URL change to make some functions and triggers on the page:

Original URL

/category/product/10

New URL

/category/product/10#addtocartbutton

URL becomes

/category/product/10?x=1

The method:

/category/product/10
/category/product/10#addtocartbutton (user clicks an onclick href to submit form)
/category/product/10?x=1 (the form adds the item to the session and appends this URL querystring)

The problem is when they press the bac b

  • 写回答

3条回答 默认 最新

  • doudun8705 2012-09-07 09:03
    关注

    In Javascript, using location.replace instead of location.href = 'new location'
    Take a look at: http://www.roseindia.net/javascript/javascript-location-replace.shtml
    -> location.replace will replace the current address by the new one -> when user click back button -> error will not happen.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度