|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
How Do I Make A Button
I want to know how to make a button using javascript for my website you know like the start button only i want it to have these features I want it to be like a push down button like when you click on it it looks like you pressed it I want it to be the color 225577 if the size can be changed I would like it to be height="30" width="80". Anyways I don't want a tutorial on java I just want the coding for the button
|
|
#2
|
||||
|
||||
|
You need to create the image of a button in an image editing application. Once you've done this, create another image, similar but slightly differnet (the mouseover image). Then, you'll need code like this to swap the image over when you mouseover:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body onLoad="MM_preloadImages('on.jpg')">
<a href="http://www.google.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('myimage','','on.jpg',1)"><img src="off.jpg" alt="Alt Text" name="myimage" width="98" height="36" border="0"></a>
</body>
</html>
|
|
#3
|
|||
|
|||
|
Sounds like im gonna be working in photo shop all day again yaeeee.
|
|
#4
|
||||
|
||||
|
CSS?!
Code:
<style type="text/css">
.button {
background-color : #257;
border : 2px outset #257;
width : 30px;
height : 30px;
}
</style>
<form>
<input type="button" id="button" class="button">
</form>
|
|
#5
|
||||
|
||||
|
I thought he wanted something more advanced than just a standard button:
Quote:
|
|
#6
|
||||
|
||||
|
yeah - it wasn't clear... u can still use form items, and style using CSS... if that is required. I forgot to mention, most importantly, that you can do away with all the JS rollover code these days, as CSS can handle most hover/focus/visited/etc stuff (cept for f**king IE on non-hyperlinked items)
Code:
<input type="image" class="imageButton">
<style type="text/css">
.imageButton {
background-image: (pic.jpg);
/* other attributes here */
}
.imageButton:hover {
/* hover state here */
}
</style>
|
|
#7
|
||||
|
||||
|
yeah, I'll agree. That CSS is neater than my javascript
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Web Design > Advanced Web Development > How Do I Make A Button |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|