CSS Image menus

Discussion in 'HTML & Website Design' started by dl77002, Jan 30, 2007.

  1. #1
    I'm tyring to make a menu for a website of photography, but I'm running into two problems. I unfortunately don't know much about CSS, so these may or may not be easy problems to solve.

    Number one is the menu on this page:
    http://bonaweiss.atspace.com/help/page1.html

    In order to see the frist page of thumbnails, you need to hover your mouse over the PAGE 1 tab. Is there a way to code it so that page 1 is shown by default? You click the link, this page opens, and you are greeted with page 1, and you can switch to page 2 by hovering over the PAGE 2 link (and back to page 1 again by hovering over PAGE 1)?


    Number two is the menu on this page:
    http://bonaweiss.atspace.com/help/newwindow.html

    I just want the photos to open in new windows, as opposed to it simply being displayed over the menu in the current window.
     
    dl77002, Jan 30, 2007 IP
  2. unitedrokz

    unitedrokz Peon

    Messages:
    86
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    for your second question...you should just be able to add this to your links to get them to open in a new window

    target="_blank"

    so for example

    <a class="horiz" href="#portrait1" target="_blank"><span><img src="thumb1.jpg" alt="" title="" /></span><em><img src="bonaweissdotcom_1.jpg" alt="" title="" /></em></a>
     
    unitedrokz, Jan 30, 2007 IP
  3. Anduril66

    Anduril66 Well-Known Member

    Messages:
    390
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    108
    #3
    For question number one, yes it is possible, but you'd have to edit the css of the stylesheet. Right now, the menu is powered by the Css ":hover" selector, and you'd have to make quite a few changes to the stylesheets to remover the :hover instructions for just the first page.

    For the second menu, I you'd have to edit the html to add the "target="_blank" " to your a links (there is no way to open a link in a new window with just css). Ie. <a href="photo.jpg" target="_blank">. You can use javascript to choose the size of the new window. You can also use Javascript to open the new windows when image links are clicked on instead of adding target="_blank" attributes to all of your links.
     
    Anduril66, Jan 30, 2007 IP
  4. dl77002

    dl77002 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks both of you, but adding "target=blank" to each link seems to only change what happens when I click the larger picture to close it. Even then, it's only opening a new tab.

    The picture is still opening in this window, and only opens a new window when I go to close it and go back to the menu.
     
    dl77002, Jan 31, 2007 IP
  5. unitedrokz

    unitedrokz Peon

    Messages:
    86
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    make sure you are doing "target=_blank" and NOT "target=blank" (notice the '_')
     
    unitedrokz, Jan 31, 2007 IP
  6. dl77002

    dl77002 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Woops, sorry. I'm doing "target=_blank", the post was just a typo.
     
    dl77002, Jan 31, 2007 IP
  7. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It's actually target="_blank" not "target=_blank". Even then, I wouldn't use it. I'd go with a combination of JavaScript and the rel attribute.

    For example:
    
    <a href="somepage.html" rel="external">Some Page</a>
    
    Code (markup):
    with the following JavaScript code in the head section (preferably in an external library file):
    
    function externalLinks() {
    	if (!document.getElementsByTagName) return;
    	var anchors = document.getElementsByTagName("a");
    	for (var i=0; i<anchors.length; i++) {
    		var anchor = anchors[i];
    		if (anchor.getAttribute("href") &&
    		anchor.getAttribute("rel") == "external")
    		anchor.target = "_blank";
    	}
    }
    window.onload = externalLinks;
    
    Code (markup):
    Just make sure that if you have other scripts that are using multiple window.onload calls, to remove them all and put them into a single function, and call them from there.
     
    Dan Schulz, Jan 31, 2007 IP
  8. dl77002

    dl77002 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Even with this, the new window only opens once I click the larger image to close it.
     
    dl77002, Jan 31, 2007 IP
  9. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You might want to consider giving each new window a unique ID (name them) so that the script can reference them. I'm not a JavaScript expert, but that should do the trick.
     
    Dan Schulz, Jan 31, 2007 IP