关于超链接传值的问题 合成一个页面,那可以通过JS定义一个全局变量吧var aa; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 框架左边是Menu,如下:<tr> <td valign="left" class="style2"> <a href="fanxingwu.asp?flag=1" target="Content">1 </a> </td> </tr><tr> <td valign="left" class="style2"> <a href="fanxingwu.asp?flag=2" target="Content">2 </a> </td> </tr> main框架:fanxingwuMain.asp:<% flag=Request.QueryString("flag") if flag=1 then 处理原1.html内容.................... else 处理原2.html内容.................... end if%> 是不是这样:<tr> <td valign="left" class="style2"> <a href="1.html#1" target="Content">1 </a> </td> </tr> <tr> <td valign="left" class="style2"> <a href="1.html#2" target="Content">2 </a> </td> </tr> 1.html中有个变量判断#后面的是1,还是2! 恩,是这样的,那么在1.html里如何检测到这个1 or 2. 谢谢,我用的是html和jsp,没用到asp。所以想知道jsp和html是如何做的。 <tr> <td valign="left" class="style2"> <a href="1.html?key=1" target="Content">1 </a> </td> </tr> <tr> <td valign="left" class="style2"> <a href="1.html?key=2" target="Content">2 </a> </td> </tr>1.html里用 search 获取 ?后面的字符串 请详细写下语句,好吗?我想达到的效果是:点击menu_advanced.html里的链接附带一个值到1.html,我不知道语法如何写。1.html 里的temp能收到链接附带过来的值,然后我在1.html里就可以针对temp来操作。menu_advanced.html:<tr> <td valign="left" class="style2"><a href="1.html?value=1" target="Content">1</a></td></tr> <tr> <td valign="left" class="style2"><a href="2.html?value=2" target="Content">2</a></td></tr> or<tr> <td valign="left" class="style2"><a href="1.html?#1" target="Content">1</a></td></tr> <tr> <td valign="left" class="style2"><a href="2.html?#2" target="Content">2</a></td></tr>1.htmlvar temp = xxxx的值就是上面的1 or 2.(就是从menu_advanced.html里点超链接传过来的值) index.html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <frameset frameborder="1" cols="30%,*"> <frame name="left" src="left.html"> <frame name="content" src=""> </frameset> <body> </body></html> left.html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <table> <tr> <td valign="left" class="style2"> <a href="1.html?1" target="content">1 </a> </td> </tr> <tr> <td valign="left" class="style2"> <a href="1.html?2" target="content">2 </a> </td> </tr> </table> </body></html>1.hmtl<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <script language="JavaScript"> window.onload = function(){ alert(document.URL.match(/[^?]+$/)); } </script> <body> </body></html> 10楼的朋友写到index.html 和 left.html ,我改写了一下1.hmtl,就无法实现ww取值,不知道是什么原因。<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Untitled Document</title></head><script language="JavaScript">init(){var ww=document.URL.match(/[^?]+$/);}</script><body onLoad="init()"><form method="post" name="f1"><script language="javascript" type="text/javascript">if(ww==1){document.write('<input id=uiViewApplyButton type=button value="123"> ');}else if(ww==2){document.write('<input id=uiViewApplyButton type=button value="456"> ');}else{document.write('<input id=uiViewApplyButton type=button value="000"> ');}</script> </form></body></html> 像下面这样改一下,另外,请注意字符集的设定。<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document </title> </head> <body onLoad="init()"> <form method="post" name="f1"> <script language="javascript" type="text/javascript"> var ww = location.href.match(/[^?]+$/); if (ww == 1) { document.write(' <input id=uiViewApplyButton type=button value="123"> '); } else if (ww == 2) { document.write(' <input id=uiViewApplyButton type=button value="456"> '); } else { document.write(' <input id=uiViewApplyButton type=button value="000"> '); } </script> </form> </body></html> 非常感谢各位,我要结贴了。大家提供了很多方法,都很管用。只要不放在加载里。index.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document </title> </head> <frameset frameborder="1" cols="30%,*"> <frame name="left" src="left.html"> <frame name="content" src=""> </frameset> <body> </body> </html> left.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document </title> </head> <body> <table> <tr> <td valign="left"> <a href="1.html?1" target="content">1 </a> </td> </tr> <tr> <td valign="left"> <a href="1.html?2" target="content">2 </a> </td> </tr></html> 1.hmtl <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document </title> </head> <script language="JavaScript"> var ww = location.href.match(/[^?]+$/);orvar ww=document.URL.match(/[^?]+$/);orww = location.search.replace(/^.*\D(\d+)$/, '$1'); </script> <body onLoad="init()"> <form method="post" name="f1"> <script language="javascript" type="text/javascript"> if(ww==1){document.write(' <input id=uiViewApplyButton type=button value="123"> ');} else if(ww==2){document.write(' <input id=uiViewApplyButton type=button value="456"> ');} else{document.write(' <input id=uiViewApplyButton type=button value="000"> ');} </script></form> </body> </html>如果还含有标记:left.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document </title> </head> <body> <table> <tr> <td valign="left"> <a href="1.html?value=1" target="content">1 </a> </td> </tr> <tr> <td valign="left"> <a href="1.html?value=2" target="content">2 </a> </td> </tr></html> 1.hmtl <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document </title> </head> <script language="JavaScript"> function GetQueryValue(name) { var reg=new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); var r=window.location.search.substr(1).match(reg); if (r!=null) return unescape(r[2]); return ""; }var ww=GetQueryValue("value");orfunction QueryString(qs){ s = location.href; var SharpIndex=s.indexOf("#"); if (SharpIndex!=-1){s=s.substring(0,SharpIndex);} s = s.replace("?","?&").split("&"); re = ""; for(i=1;i<s.length;i++){if(s[i].indexOf(qs+"=")==0){re = s[i].replace(qs+"=","");}} return re;}var ww=QueryString("value");</script> <body onLoad="init()"> <form method="post" name="f1"> <script language="javascript" type="text/javascript"> if(ww==1){document.write(' <input id=uiViewApplyButton type=button value="123"> ');} else if(ww==2){document.write(' <input id=uiViewApplyButton type=button value="456"> ');} else{document.write(' <input id=uiViewApplyButton type=button value="000"> ');} </script></form> </body> </html> JS图片轮换问题 如何实现文字翻转180度 怎么获取按键的状态? javascript dom对象增加节点的小问题 根据一个字符串 怎么new 这个类呢? 问一个表格的问题。 关于js的原型的一点问题,求指教 如何在已有的下拉筐中用鼠标或用两个按钮上下移动里头的选项?? 各路高手看一看,在线等待 5层树形结构,不知道问题出在那儿,请好心的大虾们一定一定要帮帮小虾米阿!! 这两种脚本的写法有什么不同 超链接取值
<tr> <td valign="left" class="style2"> <a href="fanxingwu.asp?flag=1" target="Content">1 </a> </td> </tr>
<tr> <td valign="left" class="style2"> <a href="fanxingwu.asp?flag=2" target="Content">2 </a> </td> </tr> main框架:
fanxingwuMain.asp:
<%
flag=Request.QueryString("flag")
if flag=1 then
处理原1.html内容....................
else
处理原2.html内容....................
end if
%>
<tr> <td valign="left" class="style2"> <a href="1.html#1" target="Content">1 </a> </td> </tr>
<tr> <td valign="left" class="style2"> <a href="1.html#2" target="Content">2 </a> </td> </tr> 1.html中有个变量判断#后面的是1,还是2!
<tr> <td valign="left" class="style2"> <a href="1.html?key=2" target="Content">2 </a> </td> </tr>1.html里用 search 获取 ?后面的字符串
我想达到的效果是:点击menu_advanced.html里的链接附带一个值到1.html,我不知道语法如何写。
1.html 里的temp能收到链接附带过来的值,然后我在1.html里就可以针对temp来操作。menu_advanced.html:<tr> <td valign="left" class="style2"><a href="1.html?value=1" target="Content">1</a></td></tr>
<tr> <td valign="left" class="style2"><a href="2.html?value=2" target="Content">2</a></td></tr>
or
<tr> <td valign="left" class="style2"><a href="1.html?#1" target="Content">1</a></td></tr>
<tr> <td valign="left" class="style2"><a href="2.html?#2" target="Content">2</a></td></tr>
1.html
var temp = xxxx的值就是上面的1 or 2.(就是从menu_advanced.html里点超链接传过来的值)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<frameset frameborder="1" cols="30%,*">
<frame name="left" src="left.html">
<frame name="content" src="">
</frameset>
<body>
</body>
</html>
left.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<table>
<tr>
<td valign="left" class="style2">
<a href="1.html?1" target="content">1 </a>
</td>
</tr>
<tr>
<td valign="left" class="style2">
<a href="1.html?2" target="content">2 </a>
</td>
</tr>
</table>
</body>
</html>
1.hmtl
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<script language="JavaScript">
window.onload = function(){
alert(document.URL.match(/[^?]+$/));
}
</script>
<body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<script language="JavaScript">
init(){
var ww=document.URL.match(/[^?]+$/);
}
</script>
<body onLoad="init()">
<form method="post" name="f1">
<script language="javascript" type="text/javascript">
if(ww==1){document.write('<input id=uiViewApplyButton type=button value="123"> ');}
else if(ww==2){document.write('<input id=uiViewApplyButton type=button value="456"> ');}
else{document.write('<input id=uiViewApplyButton type=button value="000"> ');}
</script>
</form>
</body>
</html>
另外,请注意字符集的设定。<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document </title>
</head>
<body onLoad="init()">
<form method="post" name="f1">
<script language="javascript" type="text/javascript">
var ww = location.href.match(/[^?]+$/);
if (ww == 1) {
document.write(' <input id=uiViewApplyButton type=button value="123"> ');
}
else
if (ww == 2) {
document.write(' <input id=uiViewApplyButton type=button value="456"> ');
}
else {
document.write(' <input id=uiViewApplyButton type=button value="000"> ');
}
</script>
</form>
</body>
</html>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document </title>
</head>
<frameset frameborder="1" cols="30%,*">
<frame name="left" src="left.html">
<frame name="content" src="">
</frameset>
<body> </body>
</html> left.html <html> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document </title>
</head>
<body> <table>
<tr> <td valign="left"> <a href="1.html?1" target="content">1 </a> </td> </tr>
<tr> <td valign="left"> <a href="1.html?2" target="content">2 </a> </td> </tr>
</html> 1.hmtl <html> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document </title>
</head>
<script language="JavaScript">
var ww = location.href.match(/[^?]+$/);
or
var ww=document.URL.match(/[^?]+$/);
or
ww = location.search.replace(/^.*\D(\d+)$/, '$1');
</script>
<body onLoad="init()">
<form method="post" name="f1">
<script language="javascript" type="text/javascript">
if(ww==1){document.write(' <input id=uiViewApplyButton type=button value="123"> ');}
else if(ww==2){document.write(' <input id=uiViewApplyButton type=button value="456"> ');}
else{document.write(' <input id=uiViewApplyButton type=button value="000"> ');}
</script></form> </body> </html>如果还含有标记:left.html <html> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document </title>
</head>
<body> <table>
<tr> <td valign="left"> <a href="1.html?value=1" target="content">1 </a> </td> </tr>
<tr> <td valign="left"> <a href="1.html?value=2" target="content">2 </a> </td> </tr>
</html> 1.hmtl <html> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document </title>
</head>
<script language="JavaScript">
function GetQueryValue(name)
{
var reg=new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r=window.location.search.substr(1).match(reg);
if (r!=null) return unescape(r[2]);
return "";
}
var ww=GetQueryValue("value");orfunction QueryString(qs)
{
s = location.href;
var SharpIndex=s.indexOf("#");
if (SharpIndex!=-1){s=s.substring(0,SharpIndex);}
s = s.replace("?","?&").split("&");
re = "";
for(i=1;i<s.length;i++){if(s[i].indexOf(qs+"=")==0){re = s[i].replace(qs+"=","");}}
return re;
}
var ww=QueryString("value");</script>
<body onLoad="init()">
<form method="post" name="f1">
<script language="javascript" type="text/javascript">
if(ww==1){document.write(' <input id=uiViewApplyButton type=button value="123"> ');}
else if(ww==2){document.write(' <input id=uiViewApplyButton type=button value="456"> ');}
else{document.write(' <input id=uiViewApplyButton type=button value="000"> ');}
</script></form> </body> </html>