+ Reply to Thread
Results 1 to 4 of 4

Thread: Javascript CodeCall Navigation!

  1. #1
    Code Warrior BlaineSch is a glorious beacon of light BlaineSch is a glorious beacon of light BlaineSch is a glorious beacon of light BlaineSch is a glorious beacon of light BlaineSch is a glorious beacon of light BlaineSch is a glorious beacon of light BlaineSch's Avatar
    Join Date
    Apr 2009
    Location
    Trapped in my own little world.
    Age
    19
    Posts
    2,223
    Blog Entries
    8

    Javascript CodeCall Navigation!

    Well I stole the graphics from codecall so I should atleast show you guys!

    I just made a navigation using 2 images both of which I stole from here. Basically it just remembers where you go better. I think its kinda neat. Just thought I would share

    Moving Nav

    HTML Code:
    <html>
    <head>
    <title>Moving Nav</title>
    <style>
    body {
    	background: #abab9d;
    	border: 0px;
    	margin: 0px;
    	padding:100px;
    }
    div.navigation {
    	background: url('http://i41.tinypic.com/6ga2w8.gif') repeat-x;
    	background-position: 6px 0px;
    	width:750px;
    	height:34px;
    	border: 0px;
    	padding: 0px;
    }
    div.navigation div.left {
    	float:left;
    	height:34px;
    	width:8px;
    	background:url('http://i40.tinypic.com/n3m8md.gif');
    }
    div.navigation div.right {
    	float:right;
    	height:34px;
    	width:8px;
    	background:url('http://i40.tinypic.com/n3m8md.gif') 8px 0px;
    }
    div.navigation div.active {
    	background: #39789b;
    }
    div.navigation div.float {
    	float:left;
    	font-size: 10pt;
    	color: 4a77a0;
    	text-align:center;
    }
    a.nav, a.nav:link, a.nav:visited, a.nav:hover {
    	color:white;
    	display:block;
    	margin-top: 8px;
    	height:26px;
    	width: 70px;
    	text-decoration:none;
    }
    </style>
    <script>
    	var pos = 8; //put your offset here - for me it is 8px
    	var inc = 20; //how often a move should happen
    	var moves = 7; //how many moves you wish to make
    	var width = 10; //this is how big each move is
    	var saved = 0; //dont touch this one
    	var time = 0; //dont touch this one
    	/*
    		NOTE: moves * width = link width; //in my case 7*10=70px!!!!
    	*/
    	function move(dir) {
    		if(dir == "left") {
    			pos -= width;
    			document.getElementById('navigation').style.backgroundPosition = (pos)+"px 0px";
    		} else {
    			pos += width;
    			document.getElementById('navigation').style.backgroundPosition = (pos)+"px 0px";
    		}
    		time -= inc;
    		return true;
    	}
    	function change(i) {
    		if(saved > i) {
    			zero = 0;
    			while(zero < moves*(saved-i)) {
    				time += inc;
    				setTimeout("move('left')",time);
    				zero++;
    			}
    			saved = i;
    		} else if(saved < i) {
    			zero = 0;
    			while(zero < moves*(i-saved)) {
    				time += inc;
    				setTimeout("move('right')",time);
    				zero++;
    			}
    			saved = i;
    		}
    		return true;
    	}
    	change(2);
    </script>
    </head>
    <body id="one">
    <div class="navigation" id="navigation">
    	<div class="left"> </div>
    	<div class="float" onmouseover="change(0)"><a href="#" class="nav">Link1</a></div>
    
    	<div class="float" onmouseover="change(1)"><a href="#" class="nav">Link2</a></div>
    	<div class="float active" onmouseover="change(2)"><a href="#" class="nav">Link3</a></div>
    	<div class="float" onmouseover="change(3)"><a href="#" class="nav">Link4</a></div>
    	<div class="float" onmouseover="change(4)"><a href="#" class="nav">Link5</a></div>
    	<div class="float" onmouseover="change(5)"><a href="#" class="nav">Link6</a></div>
    	<div class="right"> </div>
    
    </div>
    </body>
    </html>
    This line changes the default background one
    change(2);
    This is the active one should be the second if the one above is 2
    <div class="float active"
    All the numbers in the links need to be in order.

    I have added comments so you can easily set the width and speed and such.

  2. #2
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    Re: Javascript CodeCall Navigation!

    Very nice looking! I thought you were using the TP theme?

  3. #3
    Code Warrior BlaineSch is a glorious beacon of light BlaineSch is a glorious beacon of light BlaineSch is a glorious beacon of light BlaineSch is a glorious beacon of light BlaineSch is a glorious beacon of light BlaineSch is a glorious beacon of light BlaineSch's Avatar
    Join Date
    Apr 2009
    Location
    Trapped in my own little world.
    Age
    19
    Posts
    2,223
    Blog Entries
    8

    Re: Javascript CodeCall Navigation!

    What TP theme?

    Glad you like it!

  4. #4
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    Re: Javascript CodeCall Navigation!

    At the very bottom, to the left of Contact Us, change the theme to TP Style. That is the Total Penguin Theme.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Clipboard Game
    By Jordan in forum Games
    Replies: 3479
    Last Post: 02-18-2010, 04:10 PM
  2. CodeCall: April Newsletter, 09
    By Jordan in forum Announcements
    Replies: 13
    Last Post: 09-06-2009, 08:43 PM
  3. CodeCall: A Month in Code, October
    By Jordan in forum Announcements
    Replies: 5
    Last Post: 11-15-2008, 12:08 AM
  4. CodeCall Contest #3
    By Jordan in forum Announcements
    Replies: 3
    Last Post: 09-10-2007, 08:28 AM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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