SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <button> tag for hyperlinking

    hi again

    how can i make a button which directs to a particular URL upon clicking it?

    this is what i have so far, which is amazingly pathetic
    Code:
    <button onClick=""></button>
    thanks

    and can anyone tell me if i should use the <button>... i think i've read somewhere that this is deprecated in XHMTL 1.0 and will be removed in the next spec... is that right?

  2. #2
    SitePoint Wizard Ian Glass's Avatar
    Join Date
    Oct 2001
    Location
    Beyond yonder
    Posts
    2,384
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    onclick="location.href=URL";
    That may or may not work for you -- I give no warranties... ;-)

    As for <button>, I think it's fine in XHTML. However, if you're using this as a link, I wouldn't use <button> at all, and just apply CSS to a normal link -- that way it'll work with people without JavaScript or who don't support <button>. Oh, normal <a> links are also more accessible and search engines can follow better, too. :-)

    ~~Ian

  3. #3
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks Ian!

    i'm using a button because it's to complement a Submit button... i figured it'd be more consistent that way... could you suggest a better way? using a normal hyperlink (anchor tag) wouldn't really fit in beside the Submit button (at least to me it looks weird)... and search-engine spidering (?) is not an issue because it's an Intranet app...

    thanks!

  4. #4
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can "fake" a button with CSS. Gives this a go:
    Code:
    <html>
    <head>
    
    <style type="text/css">
    .fakebutton {
      border: medium outset #ff0000;
      background-color: #ff0000;
      text-decoration: none;
      padding: 2px;
    }
    </style>
    
    </head>
    
    <body>
    <a href="bwaf.html" class="fakebutton">Fake Button</a>
    </body>
    </html>
    Tested on Mozilla but I didn't get time to test it in IE. Tweak for best effect

  5. #5
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works in IE 5.5. It's ugly though.

    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  6. #6
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a prettier one (tweaked and checked in IE6):
    Code:
    .fakebutton {
      border: 2px outset #cccccc;
      background-color: #cccccc;
      text-decoration: none;
      padding: 2px;
      font-family: verdana;
      font-size: 10px;
      color: black;
    }
    .fakebutton:active {
      border: 2px inset #cccccc;
    }

  7. #7
    long gone but not forgotten AljapaCo's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    geeze.. all that code...

    use a form instead with hidden fields!
    T O B I A S - S T R A N D H | visit my site here
    OPERA7 /MSIE6 /FireFox 1.1/Win2000 /ADSL /17" Screen /1024x768
    god doesn't create genius, he clones me.............

  8. #8
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Los Angeles
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just use this:

    <input type=button value='Click Here' onClick="javascript: document.location.href='http://www.yoururlhere.com'">
    Do you have a career or job related web site?
    Earn 5 cents per click by joining our affiliate program.
    Click Here

  9. #9
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by AljapaCo
    geeze.. all that code...

    use a form instead with hidden fields!
    that won't work because i need the button for hyperlinking... what good is a hidden field to me

    and thanks skunk for all that help... really appreciate it ... i'm thinking Ian's should work best though i haven't tried it (i'm not willing to do it now... must wait till workday... )

    thanks everyone!


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
  •