Results 1 to 24 of 24

Thread: [RESOLVED] make entire background clickable link?

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Resolved [RESOLVED] make entire background clickable link?

    is there a way using HTML or CSS to make the entire page a clickable link?

    its the "Enter" page for the site.. and right now I have a large trans gif as the link (as well as a 10 second redirect).. but would rather have the whole page clickable...

    Thanks!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: make entire background clickable link?

    Something like this might be suitable
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
      <title>Example</title>
      <style>
        BODY.enterPage{
          cursor:hand;
        }
      </style>
      <script>
        function goto(){
          location.href = "http://www.dogpile.com"
        }
      </script>
      </head>
      <body class="enterPage"  onclick="goto();">
        <a href="www.dogpile.com">Enter</a>
      </body>
    </html>

  3. #3

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: make entire background clickable link?

    thought of something like that.. but what if browser has scripts turned off? will that still work?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: make entire background clickable link?

    this should work then right?

    <body onclick="location.href='home.html';">
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: make entire background clickable link?

    I just tried that in Firefox with javascript turned off and it didn't work.

  6. #6

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: make entire background clickable link?

    ok.. soo.. how to do this a "safe" way?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: make entire background clickable link?

    Put the whole page within an anchor tag.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: make entire background clickable link?

    Or put an anchor somewhere and use CSS to make it cover the entire viewport. (But problematic with either scrolling or IE.)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: make entire background clickable link?

    ? I need examples of either of those (still learning!!)

    if this helps.. there is NOTHING on the page but a background image
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: make entire background clickable link?

    HTML or XHTML?

  11. #11
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: make entire background clickable link?

    I'll assume HTML so here's the code including CSS

    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    
    <html lang="en">
        <head>
            <title>Test</title>
            
            <style type="text/css">
                html
                {
                    background-color: black;
                }
                
                body
                {
                    overflow: hidden;
                }
                
                body>div a
                {
                    position: absolute;
                    top: 0;
                    left: 0;
                    width: 100%;
                    height:  100%;
                    background: black url('entry.gif') center center no-repeat;
                }
            </style>
        </head>
        
        <body>
            <div><a href="main"></a></div>
        </body>
    </html>
    Change the background colour and "entry.gif" as needed.

  12. #12

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: make entire background clickable link?

    is this right? "body>div a"
    it seems that whatever I have in that section doesnt work....
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  13. #13
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: make entire background clickable link?

    That would be because you are using a bad browser ...

    It works perfectly fine in Firefox and Opera.

    Have you read the bottom two links in my signature?

  14. #14

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: make entire background clickable link?

    lol
    its because this "body>div a" should be just "div a"

    then it works perfectly!!

    I have to program for the "majority" and that means IE
    but it should work for FF & Opera as well...right?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  15. #15
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: make entire background clickable link?

    body>div is a perfectly valid, basic, part of the CSS specification. To be quite honest, I removed it and it still did not work for me in IE, but then not much does anyway.

    I have a problem with "programming for the majority", because standards are not respected and so progress is never made. But do as you see fit

  16. #16

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: make entire background clickable link?

    it didnt work??
    this is what I changed it too based on a few examples I found... body> wasnt used in the ones I saw....
    Code:
    div a
    {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height:  100%;
    background-image: url('bg_main.jpg');
    background-repeat: no-repeat;
    background-position: center;
    background-color: black;
    }
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  17. #17
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: make entire background clickable link?

    Well that's actually exactly the same as what I had, minus the body>div child combinator in the selection rule. I only put it in in case you needed multiple div's, which you probably don't anyway

    To make it work properly in IE I needed to add "height: 100%;" to the body properties.

  18. #18
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: make entire background clickable link?

    Mind you, this method won't work if the content is long enough for scrolling. In that case, the link will simply scroll away.

    position:relative;
    would ignore scrolling, but doesn't work in IE.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  19. #19

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: make entire background clickable link?

    cornedbee.. not to worry.. there is nothing but a background image on this.. no text etc...

    Thanks all!!!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  20. #20
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] make entire background clickable link?

    No problem, and PLEASE at least consider using a better browser ... it will make your life much easier.

  21. #21

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: [RESOLVED] make entire background clickable link?

    I will consider it I guess...

    I use maxthon, and I know its IE, but the features it has are just too good and so easy to use... basically its the drag link for new tab feature I cant live without

    click drag a link a 1/4 inch (so it turns to a shortcut drop cursor) and let go.. bam that link opens in a new page.. love it too much! havent found another browser that does this
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  22. #22
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] make entire background clickable link?


  23. #23
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: [RESOLVED] make entire background clickable link?

    I can middle-click links for a new tab. How's that for simple?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  24. #24

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: [RESOLVED] make entire background clickable link?

    works for me...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

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



Click Here to Expand Forum to Full Width