www.webdeveloper.com
Results 1 to 3 of 3

Thread: OnClick selection issue

  1. #1
    Join Date
    Aug 2011
    Posts
    1

    OnClick selection issue

    Hi there all I am having an issue with using an onclick menu it works fine in some ie browsers not all? and firefox but does not work at all in Safari.
    could someone please point me into the right direction as this is now driving me crazy as to get it working.

    Please HELP!!

    <select name="select">
    <option onclick="location.href='contact.html'">English</option>
    <option onclick="location.href='/main/language/francais/contact.html'">Français</option>
    <option onclick="location.href='/main/language/deutch/contact.html'">Deutch</option>
    <option onclick="location.href='/main/language/italiano/contact.html'">Italiano</option>
    <option onclick="location.href='/main/language/espanyol/contact.html'">Españyol</option>
    </select>

    help me please

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    1) Do not rely on JavaScript for navigation! It will fail for so many users that in some cases it's actually against the law.

    2) Options don't have, or aren't supposed to have, onclick handlers.

    So put that in a proper form, with a submit button, and use something like:
    Code:
    <form action="JavaScript_free_default_action.php" onsubmit=return this_part_gets_more_complicated_but_you_will_figure_it_out()">
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Mar 2011
    Posts
    1,138
    onClick is going to be unreliable for <option> tags. It would be best to add an onChange() function to the <select> tag that fetches the current selection value for your call to location.href.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles