Customize Dropdown Menu 2
- Date: 2007-11-20 - Word Count: 345
Share This!
Customize Dropdown Menu is designed to display some choices, as: languages, countries, themes,... but it's differrent from original version in browsers. This tool combine CSS and JavaScript to create a dropdown you can add image to tilte, every choice.
Version 2: check if JavaScript is disabled, then add normal dropdown menu
Let's try dropdown below and feel differences. Tested: IE 7, Opera 9, Firefox 2, Netscape 8.
Demo: http://javascriptbank.com/javascript/run-script-customize-dropdown-menu-2-index.html
/*
Customize Dropdown Menu 1.0
Author: Thái Cao Phong
Website: www.JavaScriptBank.com
Please keep these comments above to contact author when you use this script. Thank you very much.
Vietnamese: Xin ban hay giu lai nhung thong tin tren de nguoi khac co the lien he voi tac gia neu ban co
su dung doan ma nay. Cam on ban rat nhieu.
*/
img
{
vertical-align: middle;
}
.title_dropdown
{
padding: 1px;
background: url(dropdown_arrow.jpg) no-repeat right;
width: 15px;
vertical-align: middle;
border: 1px solid silver;
width: 180px;
height: 17px;
font: 12px verdana bold;
text-align: left;
cursor: hand;
}
.content_dropdown
{
position: relative;
vertical-align: middle;
border: 1px solid black;
width: 180px;
}
.content_dropdown a
{
text-decoration: none;
color: black;
}
.content_dropdown p.off
{
margin: 0px;
color: black;
padding: 3px;
padding-left: 10px;
cursor: hand;
text-align: left;
}
.content_dropdown p.on
{
background-color: #000077;
color: white;
margin: 0px;
padding: 3px;
padding-left: 10px;
cursor: hand;
text-align: left;
}
.content_dropdown img
{
width: 30px;
height: 20px;
border: none;
margin-right: 5px;
}
/*
xxxxxxxxxxxxxxx xxxxxxxxxxx xxxx
xxxxxxxxxxxxxxx xxxxxxxxxxxxx xxxx
xxxxxxxxxxxxxxx xxxxxxxxxxxxx xxxx
xxxxx xxxxxxxxxxxx xxxx
xxxxx xxxxx xxxx
xxxxx xxxxxxxxxxxx xxxx
xxxxx xxxxxxxxxxxxx xxxxxxxxxxx www.JavaScriptBank.com
xxxxx xxxxxxxxxxxx xxxxxxxxxxxxx
xxxxx xxxxx xxxx xxxx
xxx xxxxx xxxxxxxxxxxx xxxx xxxx
xxx xxxxxx xxxxxxxxxxxxx xxxx xxxx
xxxxxxxxxx xxxxxxxxxxxxx xxxxxxxxxxxxx
xxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
Customize Dropdown Menu 1.0
Author: Thái Cao Phong
Website: www.JavaScriptBank.com
Please keep these comments above to contact author when you use this script. Thank you very much.
Vietnamese: Xin ban hay giu lai nhung thong tin tren de nguoi khac co the lien he voi tac gia neu ban co
su dung doan ma nay. Cam on ban rat nhieu.
*/
var ie = navigator.appName=='Microsoft Internet Explorer'?true:false;
function toggle_dropdown(id)
{
var div = document.getElementById(id);
if(div.style.display == 'none')
div.style.display = 'block';
else
div.style.display = 'none';
}
function getObject(evt)
{
var srcElem;
if(ie)
{
srcElem = event.srcElement;
}
else
{
srcElem = evt.target;
}
return srcElem;
}
function go_any_page()
{
alert('This is example');
}
function changeStyle(pTag)
{
pTag.className = (pTag.className == 'off' ? 'on' : 'off');
}
function dropdown_on(evt)
{
var pTag = getObject(evt);
if(pTag.tagName == 'P' && pTag.parentNode.id == 'language_dropdown')
changeStyle(pTag);
}
function dropdown_off(evt)
{
var pTag = getObject(evt);
if(pTag.tagName == 'P' && pTag.parentNode.id == 'language_dropdown')
changeStyle(pTag);
}
function click(evt)
{
var pTag = getObject(evt);
if(!document.getElementById('language_dropdown'))
return;
if(pTag.tagName == 'DIV' && pTag.className == 'title_dropdown')
toggle_dropdown('language_dropdown');
else if(document.getElementById('language_dropdown').style.display == 'block')
toggle_dropdown('language_dropdown');
}
document.onmouseover = dropdown_on;
document.onmouseout = dropdown_off;
document.onclick = click;
/*// Custom Select (22-August-2007) DRAFT
// by Vic Phillips - http://www.vicsjavascripts.org.uk
function zxcInitSel(zxcid){
var zxcsel=document.getElementById(zxcid);
var zxcflag=zxcES('IMG',{position:'absolute'});
zxcflag.src=zxcsel.options[0].title;
var zxccur=(document.all)?'hand':'pointer';
var zxccsel=zxcES('DIV',{position:'relative',width:zxcsel.offsetWidth+zxcflag.width+'px',height:zxcsel.offsetHeight+'px',border:'solid black 1px',cursor:zxccur});
zxcsel.parentNode.replaceChild(zxccsel,zxcsel);
zxcES(zxcflag,{left:'2px',top:(zxccsel.offsetHeight-zxcflag.height)/2+'px'},zxccsel);
zxcES('DIV',{position:'relative',left:(zxcflag.width+2)+'px'},zxccsel,zxcsel.options[0].text);
var zxcdrop=zxcES('IMG',{position:'absolute'},zxccsel);
zxcdrop.src=zxcsel.title;
zxcES(zxcdrop,{left:(zxccsel.offsetWidth-zxcdrop.width-2)+'px',top:(zxccsel.offsetHeight-zxcdrop.height)/2+'px'});
zxcdrop=zxcES(zxccsel.cloneNode(false),{position:'absolute',visibility:'hidden',left:'-1px',top:zxccsel.offsetHeight+'px'},zxccsel);
for (var zxc0=1;zxc0*/
Choose your country
Version 2: check if JavaScript is disabled, then add normal dropdown menu
Let's try dropdown below and feel differences. Tested: IE 7, Opera 9, Firefox 2, Netscape 8.
Demo: http://javascriptbank.com/javascript/run-script-customize-dropdown-menu-2-index.html
/*
Customize Dropdown Menu 1.0
Author: Thái Cao Phong
Website: www.JavaScriptBank.com
Please keep these comments above to contact author when you use this script. Thank you very much.
Vietnamese: Xin ban hay giu lai nhung thong tin tren de nguoi khac co the lien he voi tac gia neu ban co
su dung doan ma nay. Cam on ban rat nhieu.
*/
img
{
vertical-align: middle;
}
.title_dropdown
{
padding: 1px;
background: url(dropdown_arrow.jpg) no-repeat right;
width: 15px;
vertical-align: middle;
border: 1px solid silver;
width: 180px;
height: 17px;
font: 12px verdana bold;
text-align: left;
cursor: hand;
}
.content_dropdown
{
position: relative;
vertical-align: middle;
border: 1px solid black;
width: 180px;
}
.content_dropdown a
{
text-decoration: none;
color: black;
}
.content_dropdown p.off
{
margin: 0px;
color: black;
padding: 3px;
padding-left: 10px;
cursor: hand;
text-align: left;
}
.content_dropdown p.on
{
background-color: #000077;
color: white;
margin: 0px;
padding: 3px;
padding-left: 10px;
cursor: hand;
text-align: left;
}
.content_dropdown img
{
width: 30px;
height: 20px;
border: none;
margin-right: 5px;
}
/*
xxxxxxxxxxxxxxx xxxxxxxxxxx xxxx
xxxxxxxxxxxxxxx xxxxxxxxxxxxx xxxx
xxxxxxxxxxxxxxx xxxxxxxxxxxxx xxxx
xxxxx xxxxxxxxxxxx xxxx
xxxxx xxxxx xxxx
xxxxx xxxxxxxxxxxx xxxx
xxxxx xxxxxxxxxxxxx xxxxxxxxxxx www.JavaScriptBank.com
xxxxx xxxxxxxxxxxx xxxxxxxxxxxxx
xxxxx xxxxx xxxx xxxx
xxx xxxxx xxxxxxxxxxxx xxxx xxxx
xxx xxxxxx xxxxxxxxxxxxx xxxx xxxx
xxxxxxxxxx xxxxxxxxxxxxx xxxxxxxxxxxxx
xxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
Customize Dropdown Menu 1.0
Author: Thái Cao Phong
Website: www.JavaScriptBank.com
Please keep these comments above to contact author when you use this script. Thank you very much.
Vietnamese: Xin ban hay giu lai nhung thong tin tren de nguoi khac co the lien he voi tac gia neu ban co
su dung doan ma nay. Cam on ban rat nhieu.
*/
var ie = navigator.appName=='Microsoft Internet Explorer'?true:false;
function toggle_dropdown(id)
{
var div = document.getElementById(id);
if(div.style.display == 'none')
div.style.display = 'block';
else
div.style.display = 'none';
}
function getObject(evt)
{
var srcElem;
if(ie)
{
srcElem = event.srcElement;
}
else
{
srcElem = evt.target;
}
return srcElem;
}
function go_any_page()
{
alert('This is example');
}
function changeStyle(pTag)
{
pTag.className = (pTag.className == 'off' ? 'on' : 'off');
}
function dropdown_on(evt)
{
var pTag = getObject(evt);
if(pTag.tagName == 'P' && pTag.parentNode.id == 'language_dropdown')
changeStyle(pTag);
}
function dropdown_off(evt)
{
var pTag = getObject(evt);
if(pTag.tagName == 'P' && pTag.parentNode.id == 'language_dropdown')
changeStyle(pTag);
}
function click(evt)
{
var pTag = getObject(evt);
if(!document.getElementById('language_dropdown'))
return;
if(pTag.tagName == 'DIV' && pTag.className == 'title_dropdown')
toggle_dropdown('language_dropdown');
else if(document.getElementById('language_dropdown').style.display == 'block')
toggle_dropdown('language_dropdown');
}
document.onmouseover = dropdown_on;
document.onmouseout = dropdown_off;
document.onclick = click;
/*// Custom Select (22-August-2007) DRAFT
// by Vic Phillips - http://www.vicsjavascripts.org.uk
function zxcInitSel(zxcid){
var zxcsel=document.getElementById(zxcid);
var zxcflag=zxcES('IMG',{position:'absolute'});
zxcflag.src=zxcsel.options[0].title;
var zxccur=(document.all)?'hand':'pointer';
var zxccsel=zxcES('DIV',{position:'relative',width:zxcsel.offsetWidth+zxcflag.width+'px',height:zxcsel.offsetHeight+'px',border:'solid black 1px',cursor:zxccur});
zxcsel.parentNode.replaceChild(zxccsel,zxcsel);
zxcES(zxcflag,{left:'2px',top:(zxccsel.offsetHeight-zxcflag.height)/2+'px'},zxccsel);
zxcES('DIV',{position:'relative',left:(zxcflag.width+2)+'px'},zxccsel,zxcsel.options[0].text);
var zxcdrop=zxcES('IMG',{position:'absolute'},zxccsel);
zxcdrop.src=zxcsel.title;
zxcES(zxcdrop,{left:(zxccsel.offsetWidth-zxcdrop.width-2)+'px',top:(zxccsel.offsetHeight-zxcdrop.height)/2+'px'});
zxcdrop=zxcES(zxccsel.cloneNode(false),{position:'absolute',visibility:'hidden',left:'-1px',top:zxccsel.offsetHeight+'px'},zxccsel);
for (var zxc0=1;zxc0*/
Choose your country
Related Tags: themes, countries, as languages
Your Article Search Directory : Find in Articles
Recent articles in this category:
- How to Capitalize on Free Content From Podcasts
One of the major challenges for every website owner is generating compelling content that will - Looking for a Niche? 40 Keyword Suggestions
One of the most important steps foraffiliate marketing and Internet marketing is finding a go - 5 Benefits Of Having Your Own Home Business
There is no secret to why millions of people are flocking to the internet to start their own h - Why You Should Be Using an Online Backup Service
Online BackupOnline backup services are relatively new but they are gaining popularity at the - Optimized Articles Drive Traffic to Websites
Benefits of SEO ArticlesSEO Articles can help move websites up in the search engines and are o - FREEDOM1-PACKAGE.COM/ YOUR TOP MONEY ONLINE BUSINESSES Presents:
FREEDOM1-PACKAGE.COM/ YOUR TOP MONEY ONLINE BUSINESSES!Presents:Evaluating Your Website Traffi - 3 Bonuses To Success University's Already Stellar Program
It is not very often that you will come across a program to the likes of Success University. - How to Optimize Your Website For Better Visitor Experience and More Traffic
This article describes in simple terms, practical and effective tactics used to optimize your - Do You Like Being On Top? A Global Domains International Position.
If you like to be on top then you are just like millions of other web site owners trying to po - Internet Marketer's Dream: 8 Productivity Tips for Firefox Browser Users
Here are 8 productivity tips specifically for Mozilla Firefox users:1) SearchStatus. Set your
Most viewed articles in this category:
- The Webmaster's Assistant
There are many tools available to a webmaster to analyse website traffic allowing them to monitor th - Free Webmaster Resources
The overall importance of Quality Web Development or Web Design Tools is a factor among webmast - Webmaster Staff Leasing
Some of you might be wondering what webmaster staffing means? So just to make it clear for everyone - Web Analytics - Getting It Right
Understanding and using web analytics.In recent years, website marketers were concerned with increas - 6 Steps to a More Successful Website in 2006
Another year has passed and a new one has dawned. It's an exciting time to have an online business. - Easy Content Management with Server Side Includes (part 1)
I honestly see very few websites that can really say they don’t need some sort of Content Mana - HTML Editors
If you're the typical non professional user then you are probably familiar with the more popular one - Want Your Website Visitors to Return?
If your like me you have searched on every search engine any possible way to advertise your website. - 4 Nearly FREE Ways for a Web Designer to Establish a Local Presence
Everyone seems to be a web designer these days. From your uncle’s neighbor’s nephe - Reasons why you should have a Weblogger installed on your web site.
Radhika Venkata (c).I don't know about you, but when I built my first web site threeyears back I don