-
[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!
-
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>
-
Re: make entire background clickable link?
thought of something like that.. but what if browser has scripts turned off? will that still work?
-
Re: make entire background clickable link?
this should work then right?
<body onclick="location.href='home.html';">
-
Re: make entire background clickable link?
I just tried that in Firefox with javascript turned off and it didn't work.
-
Re: make entire background clickable link?
ok.. soo.. how to do this a "safe" way?
-
Re: make entire background clickable link?
Put the whole page within an anchor tag.
-
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.)
-
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
-
Re: make entire background clickable link?
-
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.
-
Re: make entire background clickable link?
is this right? "body>div a"
it seems that whatever I have in that section doesnt work....
-
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? :)
-
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?
-
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 ;)
-
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;
}
-
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.
-
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.
-
Re: make entire background clickable link?
cornedbee.. not to worry.. there is nothing but a background image on this.. no text etc...
Thanks all!!!
-
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.
-
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
-
Re: [RESOLVED] make entire background clickable link?
-
Re: [RESOLVED] make entire background clickable link?
I can middle-click links for a new tab. How's that for simple?
-
Re: [RESOLVED] make entire background clickable link?