Forum Moderators: open

Message Too Old, No Replies

HREF with INPUT

making jump with button click

         

orion_rus

11:05 am on Dec 7, 2004 (gmt 0)

10+ Year Member



Hello world.
I have following cunstruction
<a href="..."><input type="button" value=".."></a>
But if i click button i jumps in the location only in mozilla not in IE. Anybody know the reason of it and how it can be fixed?
I'm of cause know what i can make a onclick event in the input and function what changes location. But i need a decision with href now. Anybody can help me?

Iguana

11:52 am on Dec 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think the <a> element is meant to modify the behaviour of an <INPUT>

If you had <img src=".." border=0/> instead of a button then that would work.

orion_rus

12:55 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



Of cause it would work but it's would be addition image that should be loaded.
I live in Russia. Most users of internet still using modems and each image loading is a bad desicion here)

Iguana

1:10 pm on Dec 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only other option is Javascript onClick from the button.

In Microsofts documentation "Both text and images can be included within an anchor" - it doesn't mention INPUT - same for W3C. So it seems Mozilla is doing something that breaks standards.

katana_one

1:19 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



You could also make it a normal text link and style it with CSS so that it looks like a button.

whitefiredesigns

7:47 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



here's an idea...

place this between your head tags:


<style type="text/css">
<!--

a
{
text-decoration: none;
color: #000000;
cursor: default;
}

.button
{
width: 54px;
height: 24px;
background-color: #d4d0c8;
border-top: 1px solid #ffffff;
border-left: 1px solid #ffffff;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
cursor: default;
}

.tableBorder
{
border-right: 1px solid #808080;
border-bottom: 1px solid #808080;
}

.buttonClick
{
width: 54px;
height: 24px;
background-color: #d4d0c8;
border: 1px solid #000000;

}

.tableClick
{
border-top: 1px solid #404040;
border-left: 1px solid #404040;
border-right: 1px solid #ffffff;
border-bottom: 1px solid #ffffff;

}

.cellClick
{
border-top: 1px solid #808080;
border-left: 1px solid #808080;
border-right: 1px solid #d4d0c8;
border-bottom: 1px solid #d4d0c8;

font-family: MS Sans Serif;
font-size: 14px;
color: #000000;
text-align: center;
vertical-align: middle;

}

.text
{
font-family: MS Sans Serif;
font-size: 14px;
color: #000000;
text-align: center;
vertical-align: middle;
}

//-->
</style>

<script language="javascript">
<!--
var ie = (document.all && document.getElementById);
var ns = (!document.all && document.getElementById);

function buttonDown()
{
if (ie)
{
document.all.button.className = "buttonClick";
document.all.tableID.className = "tableClick";
document.all.cellID.className = "cellClick";
}

if (ns)
{
document.getElementById("button").className = "buttonClick";
document.getElementById("tableID").className = "tableClick";
document.getElementById("cellID").className = "cellClick";
}
}

function buttonUp()
{
if (ie)
{
document.all.button.className = "button";
document.all.tableID.className = "tableBorder";
document.all.cellID.className = "text";
}

if (ns)
{
document.getElementById("button").className = "button";
document.getElementById("tableID").className = "tableBorder";
document.getElementById("cellID").className = "text";
}
}

//-->
</script>

then place this in your body where ever you'd like your button to be:


<div id="button" class="button" onMouseDown="buttonDown();" onMouseUp="buttonUp();">
<table id="tableID" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" class="tableBorder">
<tr>
<td id="cellID" class="text"><a href="http://www.here.com">Button</a></td>
</tr>
</table>
</div>

now depending on the text on your "button", you might have to change the width of the button. so you'd change the "width: 54px" in the "button" and "buttonClick" styles.

katana_one

8:51 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



My word, that's a lot of scripting/CSS for such a simple task.

The following works without JavaScript, and is not nearly as lengthy:
In the <head> of the document:


<style type="text/css">
.button a {
border:2px outset;
background:#ccc;
color:#000;
text-decoration:none;
font-weight:bold;
padding:5px;
}
.button a:active {
border:2px inset;
}
</style>

And then tag the links you want to be buttons like this:


<span class="button"><a href="MyWebLink.html">Click Me!</a></span>

That should give you a pretty good start. You can also specify the font for the button, different button colors, border thickness, etc.

mrnoisy

12:11 am on Dec 8, 2004 (gmt 0)

10+ Year Member




<form action="index.html"><input type="submit" value="index"></form>

katana_one

1:36 pm on Dec 8, 2004 (gmt 0)

10+ Year Member



Let's not make it too easy, now!
;)