• Post Reply Bookmark Topic Watch Topic
  • New Topic

Javascript and URLEncoder.encode  RSS feed

 
John Prime
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally our site used an input type="button" to allow the user to access dynamically generated data. The user would click the button and the data would be displayed on the page that was generated from the submitted command. The command was implemented using and onClick statement.
Now, our marketing department wants to turn this button into a text link. The problem I am having is that once a create an href=javascript function call, the code will work on Netscape, but will not properly encode the url data for display on IE. Can someone suggest a way I can do this using the an href=javascript function? Below is the code from the button and the javascript href.
Input button:
<input type="button" click="openClippedCouponWindow('<jsp:getProperty name="portalPartnerBean" property="portalPartnerDirectory" />/vpcore/print_frame_content.jsp?printURL=<%= URLEncoder.encode("/vpcore/print_dispatch.jsp?colorPrint=true&printType=clipped&printDestination=" + portalPartnerBean.getPortalPartnerDirectory() + "/vpcore/print_content.jsp" %> ');" value="View Coupons">
Href=javascript:
<a href="javascript isplayURL('<jsp:getProperty name="portalPartnerBean" property="portalPartnerDirectory" />/vpcore/print_frame_content.jsp?printURL=<%= URLEncoder.encode("/vpcore/print_dispatch.jsp?colorPrint=true&printType=clipped&printDestination=" + portalPartnerBean.getPortalPartnerDirectory() + "/vpcore/print_content.jsp" %> ');">Click Here</a>
Also, if I use an image, with an onClick event, it will work in IE but not Netscape. Any ideas would be greatly appreciated. By the way, I do get a responce in both browsers, but I don't get the proper encoding in IE. Below is an example of how both URL queries are encoded.
Netscape:
http://vpcoldev:90/vpcore/print_frame_content.jsp?printURL=%2Fvpcore%2Fprint_dispatch.jsp%3FcolorPrint%3Dtrue%26printType%3Dclipped%26printDestination%3D%2Fvpcore%2Fprint_content.jsp
IE:
http://vpcoldev:90/vpcore/print_frame_content.jsp?printURL=/vpcore/print_dispatch.jsp?colorPrint=true&printType=clipped&printDestination=/vpcore/print_content.jsp
 
John Prime
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, a co-worker and I finally figured out how to make it work, so sit back and I'll tell everyone how.
The problem that I was having was that the Java URLEncode method was not encoding the query string properly, so it would not work right in one browser or the other.
So to resolve the problem, we ended up making a JavaScript function, that makes an on click call to the DOM of the page. The exact part of the DOM is an input type hidden element of the form that uses an on click function with the query string in it.
So, by clicking the href link, you call the JavaScript function, which calls the on click event of the form input element. It's a very convoluted way to resolve the issue, but it works in IE on both the Mac and PC and in Netscape on both the Mac and PC.
Hope this helps anyone else who is having a similar problem.
John
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!