如何将ahref值发送到html中的另一个页面 [英] How to send ahref value to another page in html

查看:63
本文介绍了如何将ahref值发送到html中的另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将ahref值发送到html中的另一个页面

----------------------------- ---------------



hi frnds,



我有2个HTML页面,



这里我想从第一页发送值到第二页,当ahref链接点击时。



如... ....



第1页。

=========







第二页

========

它应显示为:



所选国家:埃及



请帮助我,如何做到这一点。这只是HTML项目(HTML WEBPAGES)



谢谢。

解决方案

在你的第一个html页面中你有这样的链接



 <   ul  >  <   li  >  <   a     href   =  SelectedCountry.htm > 埃及<  < span class =code-leadattribute> / a  >  <   / li  >  <   / ul  >  





将其更改为类似的内容

 <   ul  >  <   li  >  <   a     href   =   SelectedCountry.htm?country = Egypt > 埃及<   / a  >  <   / li  >  < ;  < span class =code-leadattribute> / ul  >  





在SelectedCountry.htm中你需要写一个类似下面的javascript以获得国家的价值。



< script language =   javascript> 
function getCountry()
{
var country = new String window 位置);
index = country.indexOf( =)+ 1;
countryName = country.substring(index);
document .write( 所选国家/地区: +国家名称);
}
getCountry()
< / script>



希望我理解你的意思是正确的。


How to send ahref value to another page in html
--------------------------------------------

hi frnds,

I have 2 HTML pages,

here i want to send value from first page to 2nd page, when the ahref links clicks.

such as....

1st page.
=========




2nd page
========
It should display as :

Selected Country : Egypt

Please can you help me, how to do this. This is HTML Project only (HTML WEBPAGES)

Thanks.

解决方案

In your first html page you have link like this

<ul><li><a href="SelectedCountry.htm">Egypt</a></li></ul>



change it to something like this

<ul><li><a href="SelectedCountry.htm?country=Egypt">Egypt</a></li></ul>



In "SelectedCountry.htm" you will need to write a javascript like the below one to get the value of country.

<script language="javascript">
function getCountry()
{
	var country = new String(window.location);
	index = country.indexOf("=")+1;
	countryName = country.substring(index);
	document.write("Selected Country : "+countryName);
}
getCountry()
</script>


Hope I understood what you meant in a correct manner.


这篇关于如何将ahref值发送到html中的另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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