Useful Code

Useful code snippets for CSS, Excel, HTML, Java, JavaScript, Regular Expressions, and SQL

Buttons from images

You totally CAN make an image into a button that loads a new page without JavaScript.


The usual reason for wanting to make an image into a button without using the usual link tags, i.e.,


Here's an alternative to having to define a JavaScript function for the onclick event:

    


- or -


    
onClick="location.href='index.html'">





Apply attributes using CSS:


#clickhere {
    background-image: url('pathtoimage/image.png');
    height: 20px;
    width: 75px;
}

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

My photo
Tom Beek
Interested in learning.
View my complete profile

Search This Blog

Ah, More Blogs

  • Read That
    David Sedaris Like
  • Tech Parade
    Can You Run an LLM on Your Phone?
  • Essays
    Thirteen Coffee Benefits
  • Photo Jems
    Maxim's
  • codesamples - TomBeek

Blog Archive

  • ►  2021 (1)
    • ►  December (1)
  • ►  2020 (1)
    • ►  January (1)
  • ►  2015 (1)
    • ►  January (1)
  • ►  2013 (1)
    • ►  September (1)
  • ▼  2010 (4)
    • ►  October (1)
    • ▼  September (1)
      • Buttons from images
    • ►  July (1)
    • ►  March (1)
  • ►  2009 (3)
    • ►  November (1)
    • ►  August (1)
    • ►  July (1)
  • ►  2008 (1)
    • ►  November (1)
©2009-2020 Thomas Beek