Results 1 to 11 of 11

Thread: Make a DIV a link? [Resolved]

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Make a DIV a link? [Resolved]

    Not sure why it was made like this. But at least that is how it is now...


    We have a banner on the top of the page, and we are setting the banner by setting a background picture using CSS.

    So everything we write to show the banner is:

    <div id="Topp-banner">

    </div>

    But now they want to link the banner to the index site. Is it possible to make it a link, so if anyone presses it it will go to the index page?
    Last edited by NoteMe; Jul 6th, 2004 at 06:00 AM.

  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    CAn you not make the CSS which targets the DIV target the image instead?
    Otherwise, the only thing I can think of is making a same sized transparent image and putting it on top.
    Have I helped you? Please Rate my posts.

  3. #3

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by Acidic
    CAn you not make the CSS which targets the DIV target the image instead?
    You mean like puttin in a img tag on every page and then make it a link? And then style the image with CSS? Guess I could, but I also guess that it was done the way it is now becuase then we don't have to change every page if we change the banner. But if it has the same name on all the pages I guess there won't be a big issue anyway....so if I understaood you right I guess I can do it that way..

  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    that is what I meant. I see the potential probelm though. If their server supports PHP then you could make a header.php file which you call at the start of every page. this page could have the banner thing in it. this way you only have to edit one file.
    Have I helped you? Please Rate my posts.

  5. #5

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Yeah, I guess I could do it that way...never used a header PHP file and included it before tho'

    Any example code there?


    [Edit] And yeah all pages are PHP...

  6. #6
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    I have two header files, here they are:
    header1.php:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html>
    <head>
    <link href='blue.css' rel='alternate stylesheet' type='text/css' title='blue' />
    <link href='orange.css' rel="stylesheet" type='text/css' title='default' />
    <link rel="shortcut icon" href="icon.ico" />
    header2.php:
    Code:
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
    <script src='menu.js' type='text/javascript'></script>
    <script src='misc.js' type='text/javascript'></script>
    </head>
    <?
    include "menu.php";
    $onLoad = "<body onload='CSS(),read_active_style_sheet()";
    //Now to see what file this one is and insert the correct body tag
    //Should work independant on domain.
    if (strpos($_SERVER["SCRIPT_NAME"],"index.php") >= 1)
    	{
    	$onLoad = $onLoad . ",store_updates()";
    	}
    print "$onLoad"."'>\n";
    
    if ($_SERVER["HTTP_HOST"] != "localhost")
    	{
    	print "<p><!--WEBBOT bot='HTMLMarkup' startspan ALT='Site Meter' -->
    	<script type='text/javascript'>var site='sm1acidic'</script>
    	<script type='text/javascript' src='http://sm1.sitemeter.com/js/counter.js?site=sm1acidic'></script>
    	<a href='http://sm1.sitemeter.com/stats.asp?site=sm1acidic'>
    	<img src='http://sm1.sitemeter.com/meter.asp?site=sm1acidic' alt='Site Meter' style='display: none;'/></a><br />
    	<!-- Copyright (c)2002 Site Meter -->
    	<!--WEBBOT bot='HTMLMarkup' Endspan -->";
    	}
    ?>
      <a href="http://validator.w3.org/check?uri=referer">
      <img src="http://www.w3.org/Icons/valid-xhtml11"
          alt="Valid XHTML 1.1!" height="31" width="88" /></a>
      <a href="http://jigsaw.w3.org/css-validator/"><br />
      <img style="border:0;width:88px;height:31px"
           src="http://jigsaw.w3.org/css-validator/images/vcss" 
           alt="Valid CSS!" />
     </a><br />
     <a href="http://www.mozilla.org/products/firefox/" title="Get Firefox - Web Browsing Redefined">
    	<img src="http://www.mozilla.org/products/firefox/buttons/getfirefox_88x31.png"
    	width="88" height="31" alt="Get Firefox" /></a>
    </p>
    <div id='banner'><img src='banner-orange.gif' alt='Banner' /></div>
    <div id='div_date_style'>
    <?
    echo date("l") . " the ". date("dS of F");
    ?> 
    <br />
    Change style: <input type="button" value="Orange" onclick="banner_colour('banner-default.gif'),setActiveStyleSheet('default'); return false;" />
    <input type="button" value="Blue" onclick="banner_colour('banner-blue.gif'),setActiveStyleSheet('blue'); return false;" />
    </div>
    <div id='div_menu'>
    <?
    for ($i=0; $i<count($main_list); $i++)
    	{
    	print "<b><span id='" . $main_list[$i] . "' onclick='sub_menu(this.id)' style='cursor: pointer'>" . $main_list[$i] . "</span></b><br /><br />\n";
    	}
    ?>
    </div>
    <div id='div_body'>

    then I have a footer, which I boring to post.

    Here's how my index file looks:
    index.php:
    Code:
    <? include "Templates/header.php"; ?>
    <title>Acidic Library - Home</title>
    <? include "Templates/header2.php"; ?>
    <p>
    		This site aims at providing its visitors (you) with an online library full of developers resources.
    		I write JavaScript for you to freely use on your WebPages (as long as you leave my comments in place).
    		I also offer Visual Basic applications, Flash and <acronym title="recursive acronym for PHP: Hypertext Preprocessor">PHP</acronym>
    		scripts. I supply the source code and all the files necessary for you to compile this code yourself.
    		I also host JavaScript articles for you to learn from or use as reference.
    		</p>
    		<p>
    		<? $UA = $_SERVER['HTTP_USER_AGENT']; if (strpos($UA,"MSIE") > 0) { echo "<u>"; } ?>
    		I recommend that you use <a href="http://www.mozilla.org/products/firefox">Mozilla FireFox</a> to browse this site.
    		I use <acronym title="Cascading Style Sheets">CSS</acronym>2, and I doubt <acronym title="Internet Explorer">IE</acronym> will ever get CSS right.
    		<? if (strpos($UA,"MSIE") > 0)	{ echo "</u>"; } ?>
    		</p>
    ...
    I can't be arsed pasting the rest.
    Have I helped you? Please Rate my posts.

  7. #7

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    OK...thanks...just a couple of more Qs about it...


    Is the imported file just copied in or not?

    - If it is copied I guess you don't need a doc type in botht the files?

    - And the header tags have to mach. Like you havn't closed them in the imported files.

    - And so on...

  8. #8
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    they are copied in. so exactly whats in header1.php gets put on in index.php exactly where I called for it.

    You don't have to close a tag in the header file it was opened, as long as it's closed somewhere.

    my page does validate, so I must be doing something right.

    no, you don't need a doctype in both. just the first one.
    Have I helped you? Please Rate my posts.

  9. #9

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    OK..thanks..then you are probably closing the <HEAD> tag in the index file. Even if I can't see if from what you posted.

    Thanks a lot. ØØ

  10. #10
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    actually I close <head> in header2.php
    Have I helped you? Please Rate my posts.

  11. #11

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Ohhh yeah you are right...me sorry...

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