The onclick is usually used to generate click events (non-page jumps) on the page to make certain content clickable, but this is not suitable for situations where parameters need to be passed, so it is written as a direct call to the JavaScript function: <a href=javascript: Somefunction (args) >content</a>. Note that this is problematic, the problem is that the somefunction parameter args value cannot contain spaces, otherwise the browser will assume that the content after the space is a property of the <a> tag, the correct way to write is to use quotation marks to the javascript: caused by somefunction (args). There is also a way to do not have to add this pair of quotation marks, the possibility of a space with the parameters of the escape function, and then in the somefunction with the Unescape function decoding the line. It is noteworthy that encodeURI, decodeURI and decoding are not successful.
Find the difference between escape and unescape, encodeURI and decodeURI, encodeURIComponent and decodeuricomponent three on the Internet:
Escape does not encode characters with 69: *,+,-,.,/,@,_,0-9,a-z,a-z
encodeURI does not encode 82 characters:!,#,$,&, ', (,), *,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,a-z
encodeURIComponent does not encode 71 characters:!, ', (,), *,-,.,_,~,0-9,a-z,a-z
A simple summary of the usage, when the URL is not passed, that is, pure JavaScript call with Escape, when the URL is involved, the entire URL is usually processed with encodeURI, only if the URL contains special parameters, The encodeuricomponent is used locally for this special parameter.
if (All.aData.photo! = "") {var a = escape (ALL.ADATA.WT); return "<a onclick=\" infooperation (' "+a+" ', ' "+ all.adata.thly+ "', '" +all.adata.photo+ "') \" href=\ "#\" title = ' View All ' ><font color=blue> ' + All.aData.wt.substr (0, +) + "</font></a> ";} else{var a = Escape (ALL.ADATA.WT), return "<a onclick=\" infooperation (' + + + ', ' "+all.adata.thly+" ', ' "+ all.adata.photo+ "') \" href=\ "#\" title = ' View All ' ><font color=blue> "+ all.aData.wt.substr (0, +) +" </font ></a> ";} function Infooperation (str,thyy,photo) {var url = encodeURI (contextpath+ "/business/question/wtfk/wtfkxq.jsp?str=" + str+ "&thyy=" +thyy+ "&photo=" +photo) Top.opendialog (contextpath+ "/business/question/wtfk/wtfkxq.jsp?str= "+str+" &thyy= "+thyy+" &photo= "+photo,{height:515,width:1100,title:" View Photos "});
var str =unescape ($ (). Getparmbyurl (' str ')), var thyy = $ (). Getparmbyurl (' thyy '); var photo = $ (). Getparmbyurl (' photo ');
Uncaught syntaxerror:unexpected token illegal JS pass parameters with spaces