• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

?? about js and redirect

 
Yu Chen
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, if I have the following jsp file that is triggered when user clicks on a link through a JS onclick handler, would the JS code be executed first before the redirect ?

Thanks all.
-yc

<%
String chName = request.getParameter("chName");
out.println("<script language=\"JavaScript\">");
out.println("var chName=\"" + chName + "\";");
out.println("</script>");
%>
<script language="JavaScript" type="text/javascript"><!--
if(eMetrics == true) {
var _rsCI="...";
var _rsCG=chName;
...
var _rsND=_rsLP+'//something.com/';
if (parseInt(navigator.appVersion)>=4) {
...
_rsCL='<scr'+'ipt language="JavaScript" type="text/javascript" src="'+_rsND+'v5.js"></scr'+'ipt>';
} else {
_rsCL='<img src="'+_rsND+'cgi-bin/m?ci='+_rsCI+'&cg='+_rsCG+'&si='+_rsSI+'&rp='+_rsRP+'">';
}
document.write(_rsCL);
}
//--></script>
<%
response.sendRedirect(targetHref);
%>
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
378
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the javascript will execute first. I assume you set the target for the redirect in the Java code on the page and not the javascript?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic