SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Can javascript be added to radio buttons?

    Hello,
    I have 2 radio buttons. When the user picks one option, I want my website to be saved as a bookmark. If the user picks the other radio button, i want my website to become their new homepage. How can I do this using javascript with my radio buttons. This is the code I have thus far:

    Code:
    <form>
            <p>
              <label>
              <input name="RadioGroup1" type="radio" onClick="MM_callJS('this.style.behavior=\'url(#default#homepage)')"   >
              <a href="this.style.behavior='url(#default#homepage)">Make this your homepage!</a></label>
              <br>
              <br>
              <label>
              <input name="RadioGroup1" type="radio" onClick="MM_callJS('javascript:addbookmark()')">
              <a href="javascript:addbookmark()">Make this your favorite!</a></label><br>
              <br>
            </p>
            </form>
    Please help!

  2. #2
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    Well...

    You actually can't anymore because of various changes in security for the recent browsers. You'll basically have to just let your users know how to change it themselves.

    You can try:
    Code:
    window.external.AddFavorite(url)
    for the bookmark and
    Code:
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage(window.location.href);
    for the homepage, but it's not going to work for 95&#37; of your users.

    As far as the onclick for radio buttons goes, that'll work just like any other input.


Bookmarks

Posting Permissions

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