local-host 2009-01-02 06:42 采纳率: 100%
浏览 790
已采纳

使用 jQuery 获取当前的 URL?

I am using jQuery. How do I get the path of the current URL and assign it to a variable?

Example URL:

http://localhost/menuname.de?foo=bar&number=0

转载于:https://stackoverflow.com/questions/406192/get-current-url-with-jquery

  • 写回答

30条回答

  • 谁还没个明天 2009-01-02 06:57
    关注

    To get the path, you can use:

    var pathname = window.location.pathname; // Returns path only
    var url      = window.location.href;     // Returns full URL
    var origin   = window.location.origin;   // Returns base URL
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(29条)

报告相同问题?

悬赏问题

  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败