• Post Reply Bookmark Topic Watch Topic
  • New Topic

set focus in textfield in WPS  RSS feed

verduka fox
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a request to set the focus into a portlet's textfield when the page loads. Since we don't have access to the HTML body tag to add 'on_load=document.myform.mytextfield.focus();', I tried doing the following in the endPage(). It doesn't work when the page is first displayed, but if you refresh the page by clicking on the selected tab, it does work. Can anyone explain why it only works sometimes?

PrintWriter writer = response.getWriter();
writer.println("<script for=\"window\" EVENT=\"on_load\" LANGUAGE=\"JavaScript1.2\">");
writer.println("try {");
writer.println("catch(e) { }");

When I view the source of the HTML, it looks like this:

<script for="window" EVENT="on_load" LANGUAGE="JavaScript1.2">
try {
catch(e) { }

FYI, We use WPS 5.1.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!