
在thisUPage = ;与windowsetTimeout之间做处理就好,根据你的情况,你可以选择用普通字符串处理或者正则表达式。
如果用split的话就是:
dashPos = thisUPageindexOf('_');
if(dashPos != -1) {
dotPos = thisUPageindexOf('');
if(dotPos != -1)
thisUPage = thisUPagesubstr(0, dashPos) + thisUPagesubstr(dotPos);
}
这种方式理解方便但是代码量多
如果用正则表达式:
thisUPage = thisUPagereplace(/_+\html/i, 'html');
代码少但是需要理解正则表达式
alert(locationhref);
这就是具体代码,你还想要怎么具体
<script language="javascript">
alert(locationhref);
</script>
你好你是想取出这9个值是吗?
稍等上代码!!
js:
<script type="text/javascript">var url = "jieguohtmzhph&zh_1&zh_2&zh_3&zh_4&zh_5&zh_6&zh_7&zh_8";
var arr = urlsubstr(urllastIndexOf('')+1)split('&');
//locationhref = url;
consolelog(arr);
</script>
输出结构是一个数组:
希望能帮到你,有问题再追问!
需要准备的材料分别有:电脑、html编辑器、浏览器。
1、首先,打开html编辑器,新建html文件,例如:indexhtml。
2、在indexhtml中的<script>标签,输入js代码:documentbodyinnerText = locationsearch;。
3、浏览器运行indexhtml页面,此时url后面的数据被获取到并打印出来。
在许多时候我们在用iframe的时候都会做分页 *** 作 iframe内部的url跳转将不能直接通过iframe的src属性来获得
iframe的当前url的获取方法
代码如下:
parentdocumentgetElementById("content_info")contentWindowlocationhref
其中:content_info为iframe的id
<!DOCTYPE html>
<html>
<head>
<title>子窗口</title>
<script type="text/javascript">
documentwrite(windowparentdocumentURL);
</script>
</head>
<body>
</body>
</html><!DOCTYPE html>
<html>
<head>
<title>父窗口</title>
</head>
<body>
<-- 需要与子窗口保持在同一目录下,或修改此处连接地址 -->
<iframe src="childhtml" style="width:500px;height:500px;"></iframe>
</body>
</html>
这个需要在IE中查看,如果要用谷歌浏览器,需要部署到服务器上。
var url= windowlocationhref
var ss = urlsplit('/');
for(var i =0 ;i<sslength;i++){
if(ss[i]=='goods_id')
alert(ss[i+1])
if(ss[i]=='city_code')
alert(ss[i+1])
}
以上就是关于js获取网页url的问题全部的内容,包括:js获取网页url的问题、如何使用js获取url、js 如何取url传过来的值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)