如何使用js得到网页路径?
我想通过进入http://www.haoku99.com/play/?5987-2-0.html以后用js代码得到这个路径→play/?5987-2-0.html 这个路径<iframe border='0' vspace='0' hspace='0' marginwidth='0' marginheight='0' framespacing='0' frameborder='0' scrolling='no' width='720' height='500' align='center' src='http://www.haoku99.com/520(这里写得到到路径)'></iframe>也就是说我要让这个iframe 的src值变成http://www.haoku99.com/520play/?5987-2-0.html提前谢谢CSDN的兄弟姐妹们
我想通过进入http://www.haoku99.com/play/?5987-2-0.html以后用js代码得到这个路径→play/?5987-2-0.html 这个路径<iframe border='0' vspace='0' hspace='0' marginwidth='0' marginheight='0' framespacing='0' frameborder='0' scrolling='no' width='720' height='500' align='center' src='http://www.haoku99.com/520(这里写得到到路径)'></iframe>也就是说我要让这个iframe 的src值变成http://www.haoku99.com/520play/?5987-2-0.html提前谢谢CSDN的兄弟姐妹们
<script type="text/javascript" language="javascript">
var html = window.location.href;
var host = window.location.host;
var o = html.replace(host,"");
alert(o);
</script>
var str = window.location.href;
var re = /^http:\/\/www\.haoku99\.com\/(.+)$/;
str = str.replace(re,"$1");
document.getElementById("if1").src="http://www.haoku99.com/520"+str;
}<iframe id='if1' border='0' vspace='0' hspace='0' marginwidth='0' marginheight='0' framespacing='0' frameborder='0' scrolling='no' width='720' height='500' align='center' src=''></iframe>
<script type="text/javascript" language="javascript">
var html = "http://www.haoku99.com/play/?5987-2-0.html" var arr=html.split("/");
alert("/"+arr[3]+"/"+arr[4]);
</script>
<script type="text/javascript" language="javascript">
var html = "http://www.haoku99.com/play/?5987-2-0.html"
var arr=html.match(/\/\/[\w.]+(.+)/g);
alert(RegExp.$1);
</script>再来!