如何在HTML中的href中使用url参数 [英] How can I use url parameter in href in HTML

查看:1170
本文介绍了如何在HTML中的href中使用url参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的网址

www.codeproject.com/Questions/ask.aspx?Ques=200

问题是动态的

i想在另一个网址中使用这个问题作为href

使用html



我尝试了什么:



I have url like this
www.codeproject.com/Questions/ask.aspx?Ques=200
Ques is dynamic
i want to use this ques in another url as href
using html

What I have tried:

<a href="../ISReports/TeachersList.aspx?Inst_code=%20@Ques"></a>

推荐答案

试试这个,



从网址中读取查询字符串值 [ ^ ]和app将值结束到网址。

使用 onclick 事件调用javascript函数导航到带有修改后的查询字符串的链接。

try this,

Read the query string value from url[^] and append the value to the url.
use onclick event to call the javascript function to navigate to the link with modified query string.
<a onclick="goToLink()" href="#">Link Name</a>




function goToLink() {
          var url = '../ISReports/TeachersList.aspx?Inst_code=';
          var ques = getParameterByName('Ques');
          url = url + ques;
          window.location = url;
      }


这篇关于如何在HTML中的href中使用url参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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