ITPUB??ì3
ITPUB论坛 » Web开发 » ASP.NET与AJAX » 获取网页中URL


标题: 获取网页中URL
离线 zly526
一般会员



精华贴数 0
个人空间 0
技术积分 196 (9457)
社区积分 0 (1201639)
注册日期 2006-12-7
论坛徽章:1
开发板块每日发贴之星     
      

发表于 2006-12-8 15:25 
获取网页中URL

如何能够获取网页中用脚本提交的连接地址?
小弟自知这个问题有点难度,请热心的高人写个通用的算法,能够获取各种脚本提交的连接地址.小弟不胜感激


源文件:

<html>
<head></head>
<body>
   <table>
        <tr>
          <td><a href="http://www.baidu.com">百度</a></td>
          <td><a onclick="SumbitClick()">测试</a></td>
          <td><a onclick="SumbitClick2(2)">测试2</a></td>
          <td><a onclick="SumbitClick3(3)">测试3</a></td>
          <td><a onclick="SumbitClick4(4,5)">测试4</a></td>
          <td><img src="http://www.sohu.com"></img></td>
        </tr>
   </table>
</body>
</html>
<script language=javascript>
function SumbitClick()
{
        location.href="index.aspx?id=110";
}
function SumbitClick2(ids)
{
        location.href="index2.aspx?id="+ids;
}
function SumbitClick3(ids)
{
        document.Form1.action = "index3.aspx?id="+ids;
}
function SumbitClick4(ids,ids2)
{
        location.href="index4.aspx?id="+ids+"&id2="+ids2;
}
</script>

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

我要的结果;
http://www.baidu.com
index.aspx?id=110
index2.aspx?id=2
index3.aspx?id=3
index4.aspx?id=4&id2=5


只看该作者    顶部
离线 mm_xlhy123
一般会员



精华贴数 0
个人空间 0
技术积分 90 (17761)
社区积分 0 (1204768)
注册日期 2006-12-7
论坛徽章:0
      
      

发表于 2006-12-8 15:27 
function getID()
        {
     var str=window.location.toString() ;
     if(str.indexOf("?"!=-1)
     {
        str=(((((str.split("?")[1]).split("&")[0]).split("=")[1];
     }else str="0000000000";
     
     return str;
                  }
var str ;
                function getURL()
                {
                           str= getID();
changePage(1);                             
                }
                function changePage(nu)
             {
               switch(nu)
               {
               
                case 1:
                           
                content.location.href="MusicCollection.aspx?id="+str;                 
                break;
               
                case 2:               
                content.location.href="DooDleShow.aspx?id="+str;                 
                break;
                                
                case 3:               
                content.location.href="DiaryBrowseAll.aspx?id="+str;               
                break;
                 
                case 4:               
                content.location.href="DiaryBrowseAll.aspx?id="+str;
                break;                                
               }
             }
                </script>



<area shape="rect" coords="11,11,34,83" href="http://###" target="iframe" />
  <area shape="rect" coords="35,23,63,81" onclick="changePage(1);" target="iframe" />
  <area shape="rect" coords="61,14,82,83" onclick="changePage(2);" target="iframe" />
  <area shape="rect" coords="82,5,100,83" onclick="changePage(3);" target="iframe" />
  <area shape="rect" coords="102,24,130,78" onclick="changePage(4);" target="iframe" />


看的懂吧`~??????????


只看该作者    顶部
离线 zly526
一般会员



精华贴数 0
个人空间 0
技术积分 196 (9457)
社区积分 0 (1201639)
注册日期 2006-12-7
论坛徽章:1
开发板块每日发贴之星     
      

发表于 2006-12-8 15:43 
不是很明白


只看该作者    顶部
离线 mm_xlhy123
一般会员



精华贴数 0
个人空间 0
技术积分 90 (17761)
社区积分 0 (1204768)
注册日期 2006-12-7
论坛徽章:0
      
      

发表于 2006-12-8 15:44 
函数 getID()   先截取URL传代的参数

总的说就是 截取URL 如 www.baidu.com?id=123123
获取id=后面的参数`
在付值给str
你要的结果
index.aspx?id=110
index2.aspx?id=2
index3.aspx?id=3
index4.aspx?id=4&id2=5
这个我也不懂 难道你的是多用户ID? 传的页面参数也不同?


只看该作者    顶部
 
    

相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰广域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:010037号 联系我们 法律顾问