• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to set focus on a button in mozilla

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have written a confirmation page in Struts which contains 1 label field "Username" and 2 buttons "Yes" & "No" respectively.

In IE when user navigates to the confirmation page I set the focus to the "Yes" button using following javascript code:



The above code works in IE

In Mozilla I tried to set focus on the button using the following code:

The above code does not work.

My observations:

For Mozilla browser:If I add any text field in the above confirmation page and set focus to it then whenever the user press enter key the "Yes" button is clicked. The code is as follows:
Javascript code:


Struts code (Addition of extra text field)

Problem:
I am not able to set focus on "Yes" button using javascript for Mozilla browser.I want that whenever user navigates to confirmation page and press enter key then "Yes" button should be selected.

Note: There is only a label field on my confirmation page and no text field

I have posted this question in this forum because I am using javascript to set focus on the buttons

Complete Code:


Please help me. I am struggling from last 2 days.

Thanks and regards.
[ April 18, 2008: Message edited by: Sahil Saxena ]
 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


First and foremost, if you have more than one component with same ID it ought to create problems.


The above should work for IE as well as mozilla. You have written the script tag as part of body which is perfectly fine but, it's better to categorise it in functions. Moreover, just try and call the above line of code directly on*load event of body tag and check across browsers. It should work.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best thing you can always do is view the page source and see what the serverside controls are outputting. Looking at a serverside tag never tells you anything.

Eric
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry , i want to with out javascript ,

i want to confirmation page in struts2.x and also with out javascript.

please reply with code
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seshagiri veerla:
please reply with code

Not going to happen. Here, you write your own code and get help with it. This is not the place to come to get others to do your work for you,
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic