从URL抓取一个部分,并使用jQuery将其附加一个链接 [英] Grab a section from a URL and append it a link using jQuery

查看:72
本文介绍了从URL抓取一个部分,并使用jQuery将其附加一个链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这超出了我的能力范围,但我要实现的目标是从URL中提取一个部分并将其附加到href链接.

This a tad beyond my capability but what I'm trying to achieve is take a section from a URL and append it to a href link.

 <a href="http://www.mysite.com.au/?SQ_DESIGN_NAME=print">Print this page</a>

这链接到我们正在使用的CMS中的仅打印页面"设计

This links to a 'Print Only Page' design in a CMS we're using

我要在初始网址之后附加的部分示例

Sample of a section I'm trying to append to after the initial URL

 course_cd=802AA&version_number=5& 

所以我结束了

 <a href="http://www.mysite.com.au/somepage/course?course_cd=802AA&version_number=5&SQ_DESIGN_NAME=print">Print this page</a>

如您所见,我要添加的部分位于?"之间.和SQ_DESIGN_NAME = print

As you can see the section I want added goes in between the '?' and the SQ_DESIGN_NAME=print

我希望这是有道理的 预先谢谢你

I hope this makes sense Thank you in advance

推荐答案

最终弄清楚了我的问题.感谢所有给我时间的人

finally figured out my problem. Thanks to everyone who gave me their time

 $(document).ready(function() {

  var path = window.location.pathname;
  var query = window.location.search;
  $('a#print').attr('href', path + query + '&SQ_DESIGN_NAME=print');

});

这篇关于从URL抓取一个部分,并使用jQuery将其附加一个链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆