dsxay48646 2018-08-26 01:57
浏览 98

php如何在命令行中传递一个锚点

I need to pass parameters and an anchor in a php program to make sure the cursor is positioned at the last place it was in the page when it returns.

program.php?ID=123&ID2=456#777

ID=123

ID2=456

html anchor is #777

Can someone tell me how to make this work? Since it isn't working the way I'm doing it now. Thanks

  • 写回答

1条回答 默认 最新

  • dongleiqiao2107 2018-08-26 05:02
    关注

    The browser will not send the anchor to web server.

    So PHP can't get the anchor from url.

    maybe you can use javascript to request program.php?ID=123&ID2=456&anchor=777, then you can get the anchor by $_GET['anchor'].

    Sorry for my bad english (ㄒoㄒ).


    If you want force the cursor to the position.

    this code will redirect to http://website.com/page.php#anchor and the broswer will auto cursor the position.

    <?php
    header("location: http://website.com/page.php#anchor");
    exit;
    

    warning: take care about header function, there is the manual header function

    If the current page is the same as the redirect page, above the code will infinite redirect and the browser will throw error. So you have to write some logic, make it redirect when you want. Or just write two different page, one to show content, other one redirect to content page with anchor.

    But I still think it is better to do that by JavaScript.

    评论

报告相同问题?

悬赏问题

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