Page 1 of 1
The Color of links
Posted: Fri Jul 26, 2002 2:47 pm
by bedcor
is there a way of stopping a link from changing colors when you click it?
my link <a href...........>.......</a> starts off as blue then when i click it, it turns bright yellow? then when i close the web page and then re-open it, the links are still yellow?
Posted: Fri Jul 26, 2002 3:18 pm
by RandomEngy
This will make all of your links pure blue:
Code: Select all
<body link="#0000FF" alink="#0000FF" vlink="#0000FF">
The link is a regular unvisited link, the alink is the color after you click on it, and the vlink is the color of visited links. If those colors are not specified, the browser picks them.
Posted: Fri Jul 26, 2002 3:20 pm
by twigletmac
The best way to do this is to use style sheets (CSS). If you've never used CSS before start here:
http://www.devshed.com/Client_Side/Style_Sheets
The link and alink attributes in the body tag have been deprecated.
The following declaration in a style sheet will cause all links that have been visited or not to be the same colour and gives you a different colour for links when they are hovered over:
Code: Select all
A:link, A:visited {
color: #ffffcc; /*change the colour to what you want */
}
A:hover {
color: #ffcccc; /* change the colour when you hover over the link */
}
Mac
Posted: Fri Jul 26, 2002 3:21 pm
by MattF
Or use CSS...
Posted: Fri Jul 26, 2002 3:23 pm
by RandomEngy
D'oh! It appears my solution has been deprecated. I don't see what's wrong with it though. :/
Posted: Fri Jul 26, 2002 3:59 pm
by bedcor
how do i use CSS in a php script?
if ($start > 0)
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 1) . "\"><center> Previous</center></a>\n\n\n";
if($numrows > ($start + 1))
echo "<a href=\"" . $PHP_SELF . "?start=". ($start + 1) . "\"><center>Next</center></a><BR>";
Posted: Fri Jul 26, 2002 4:04 pm
by MattF
If you post twiglets code in the head of your document between a <style type="text/css"> and a </style> then it will work for all links in your page. If you want do it for individual links you can do <a href="page.html" style="color:blue;">Text</a> or using a class, defined in the style tags in the head like this:
Code: Select all
.special{
color:blue;
font-family: Verdana,Sans;
font-size: 10pt;}
and added to the link like this: <a href="test.html" class="special">Text</a>
Posted: Fri Jul 26, 2002 4:06 pm
by fatalcure
heh, thats funny
It doesnt matter if your using php, using a CSS file treats all <a> tags the same, weather it be in a php script or not...
read twigletmac's post above and follow his link.
Posted: Fri Jul 26, 2002 4:24 pm
by bedcor
I'm glad i could make some people laugh with my questions!
Thanks for the tips! I got it to work. I used MattF's tip on doing it individually by link.
Thanks again!
One more question!
When i load my form, the first record is displayed and users can browse the contents with the "Next" and "Previous" links. I added a reset button
to clear the form, but when i press it it doesn't do anything?
echo "<input type=reset value=Reset>"
Posted: Sat Jul 27, 2002 2:23 am
by gnu2php
The reset button doesn't actually
clear the form, it just
resets the input fields to their default settings.
You can clear all the fields with a simple JavaScript:
Code: Select all
<input type="reset" value="Reset" onClick="clear_form(document.form_name); return false">
<!-- Or you could use document.formsї0] instead -->
<script language="JavaScript">
<!--
function clear_form(form_obj)
{
for (var x = 0; x < form_obj.elements.length; x++)
{
var type = form_obj.elementsїx].type;
if (type == 'checkbox' || type == 'radio')
{
// These must be cleared this way:
form_obj.elementsїx].checked = 0;
}
else if (type != 'submit' &&
type != 'reset' &&
type != 'hidden') // Don't clear these
{
form_obj.elementsїx].value = '';
}
}
}
//-->
</script>
Note that this doesn't clear <select> fields in Netscape.
Posted: Sat Jul 27, 2002 3:42 am
by twigletmac
Remember that if you do it individually by link then when you change your mind as to how it should appear you have to change every single link. The reason why CSS is so useful is that if you have it separate - ie. separate style from layout - then you only have to change one thing to change a whole site or page...
Please use the link to devshed and read about style sheets.
Mac
Posted: Sat Jul 27, 2002 10:06 am
by volka
and that's why I like the microsoft extension "behaviour".
Is there something similar as web-standard?