Home > Web Front-end > JS Tutorial > How to pass static url in javascript_javascript skills

How to pass static url in javascript_javascript skills

WBOY
Release: 2016-05-16 19:14:26
Original
815 people have browsed it






无标题 1






<script> <br>function ImgClick(){ <br>var hhj; <br>hhj=document.getElementById("testImage").getAttribute("src"); <br>window.location="http://www.jsjdzx.com/bbs/images/upfile/200753182445.htm?testImage=" hhj; <br>} <br></script>
传图片地址



处理页面:

复制代码 代码如下:




示例
<script> <br>function QueryString() <br>{//构造参数对象并初始化 <br>var name,value,i; <br>var str=location.href;//获得浏览器地址栏URL串 <br>var num=str.indexOf("?") <br>str=str.substr(num 1);//截取“?”后面的参数串 <br>var arrtmp=str.split("&");//将各参数分离形成参数数组 <br>for(i=0;i < arrtmp.length;i ){ <BR>  num=arrtmp[i].indexOf("="); <BR>  if(num>0){ <br>   name=arrtmp[i].substring(0,num);//取得参数名称 <br>   value=arrtmp[i].substr(num 1);//取得参数值 <br>   this[name]=value;//定义对象属性并初始化 <br>   } <br>} <br>} <br>var Request=new QueryString();//使用new运算符创建参数对象实例 <br></script>



<script> <br>var newElement=document.createElement("div");//创建div对象 <br>var str="图片地址为:<u>" Request["testImage"] "</u>";//利用实例["字段名称"]获取参数内容 <br>newElement.innerHTML=str; <br>document.body.appendChild(newElement);//向文档添加div对象 <br></script>



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template