SoFunction
Updated on 2025-04-09

How to pass static url in javascript

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Unt title 1</title>
</head>

<body>
<div >
<img src="/images/blue/" alt="test image" name="testImage"  />
</div>
<script>
function ImgClick(){
var hhj;
hhj=("testImage").getAttribute("src");
="/bbs/images/upfile/?testImage="+hhj;
}
</script>
<a href="javascript:ImgClick();" onclick="javascript:ImgClick();">Transfer the image address</a>
</body>

</html>
Processing page:
Copy the codeThe code is as follows:

<Html>
<Head>
<Meta http-equiv="Content-Type"content="text/html; charset=gb2312">
<Title>Example</Title>
<script>
function QueryString()
{//Construct the parameter object and initialize it
var name,value,i;
var str=;//Get the browser address bar URL string
var num=("?")
str=(num+1);//Seave the parameter string after "?"
var arrtmp=("&");//Separate each parameter to form a parameter array
for(i=0;i < ;i++){
  num=arrtmp[i].indexOf("=");
  if(num>0){
name=arrtmp[i].substring(0,num);//Get the parameter name
value=arrtmp[i].substr(num+1);//Get parameter value
this[name]=value;//Define object properties and initialize
   }
}
}
var Request=new QueryString();//Create parameter object instance using the new operator
</script>
</Head>

<Body>
<script>
var newElement=("div");//Create a div object
var str="The image address is: <u>"+Request["testImage"]+"</u>";//Use the instance ["field name"] to obtain the parameter content
=str;
(newElement);//Add a div object to the document
</script>

</Body>
</Html>