aspose file tools*
The moose likes Servlets and the fly likes ?? about js and redirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "?? about js and redirect" Watch "?? about js and redirect" New topic
Author

?? about js and redirect

Yu Chen
Greenhorn

Joined: Feb 11, 2002
Posts: 17
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

Joined: May 26, 2003
Posts: 31057
    
232

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?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ?? about js and redirect