Quoted http://blog.csdn.net/shenshen123jun/article/details/18078291
<span style= "FONT-SIZE:18PX;" >var restid= 2;//JavaScript Variablesfunction A () {//JavaScript functionswindow.open ("Shownews.aspx?id=" +restid);}</script> var str1,str2 str1= "FDSGDG dsfdsf China"str2= "Wuhan Rtvu"document.write ("Display string 1:" +str1+ "<br>") document.write ("Display String 2:" + str2 + "<br>") //the document.write () function is important to write so that you can read the JavaScript parameters correctly.<span style= "color: #ff6666;" >//mode One, open a new window, go to the new link</span> document.write ("<a href= ' shownews.aspx?id=" +restid+ "' style= ' text-decoration:none; color:Black; ' t arget= ' _blank ' > target page </a>) </script><span style= "color: #ff9966;" >//mode Two, use Javascript:location.href, but cannot open link in new window</span> <a href= "javascript:location.href= ' shownews.aspx?id= ' + restid" style= "text-decoration:none; Color:black; " target= "_blank" > target page </a><span style= "color: #33cc00;" >//way three, use Javascript:open, only in Sogou browser open, in IE, Firefox, 360 browser inside can not open, that means this method is not very good</span> <a href= "Javascript:open (' shownews.aspx?id= ' + restid)" style= "Text-decoration:none; Color:black; " target= "_blank" > target page </a><span style= "color: #ff6666;" >//mode four uses window.open but the mouse is the arrow instead of the hand type that represents the link,</span> <a onclick= "window.open (' shownews.aspx?id= ' + restid)" style= "Text-decoration:none; Color:black; " target= "_blank" > target page </a><span style= "color: #009900;" >//mode Five calls the JavaScript function, but the mouse is the arrow instead of the hand type that represents the link,</span><a onclick= "javascript:a ()" style= "Text-decoration:none; Color:black; " target= "_blank" > target page </a></form></body></span>
Several methods of HTML calling JS variables and functions