add underline and yellow font to this script, how?

C

Collon

Below is a simple spam blocker for email addresses on webpages...but I don't
know how to change the color to yellow for the email link. Also, I'd like
the email address to be underlined. Any help here? THANKS!


<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var user;
var domain;
var suffix;
function jemail(user, domain, suffix){
document.write( '<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix
+ '">' + user + '@' + domain + '.' + suffix + '</a>');
}
//-->
// End -->
</script>


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
jemail("pay", "nothanks", "com");
// End -->
</script>
 
R

RobG

For the record, Java has nothing to do with javascript.

Below is a simple spam blocker for email addresses on webpages...but I don't
know how to change the color to yellow for the email link. Also, I'd like
the email address to be underlined. Any help here? THANKS!

<SCRIPT LANGUAGE="JavaScript">

The language attribute has been deprecated for years, type is
required.

<!-- Begin

Don't use HTML comment delimiters inside script elements.
var user;
var domain;
var suffix;
function jemail(user, domain, suffix){

The identifiers in a formal parameter list declare local variables
with the same name. There is no point in the global declarations of
the same identifier names above unless they are used elsewhere.

Assignment of values to the local variables will not affect their
global counterparts.

document.write( '<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix
+ '">' + user + '@' + domain + '.' + suffix + '</a>');}

Add a class attribute with an appropriate value. Add a class to your
style sheet with rules to style elements with that class value however
you want. If you need help with that, there is always
comp.infosystems.www.authoring.stylesheets
 
T

Trevor Lawrence

Collon said:
Below is a simple spam blocker for email addresses on webpages...but I
don't know how to change the color to yellow for the email link. Also, I'd
like the email address to be underlined. Any help here? THANKS!


<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var user;
var domain;
var suffix;
function jemail(user, domain, suffix){
document.write( '<a href="' + 'mailto:' + user + '@' + domain + '.' +
suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
}
//-->
// End -->
</script>


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
jemail("pay", "nothanks", "com");
// End -->
</script>

Hmm.
You can add a <span style=...></span>

Below is my test code. Because yellow does not show very well on white (the
default background colour), I changed it to black. <a> tags are underlined
automatically, but I did find that adding the text-decoration changed the
underline colour to yellow rather than the default, which was blue for me

BTW,
user, domain and suffix are all parameters to the call. Declaring them
before that makes them extraneous global variables.

<html>
<head>
<script type="text/javascript">
function jemail(user, domain, suffix){
document.write( '<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix
+ '"><span
style="background-color:black;color:yellow;text-decoration:underline;">' +
user + '@' + domain + '.' + suffix + '</span></a>');
}
</script>
</head>
<body>
<script type="text/javascript">jemail("pay", "nothanks", "com")</script>
</body>
</html>
 
T

Thomas 'PointedEars' Lahn

Collon said:
Below is a simple spam blocker for email addresses on webpages... [...]

It is a user feedback blocker. And given your clueless From and Newsgroups
headers, that is all to be said about it.


comp.lang.java removed, f'up2 c.l.js

PointedEars
 
R

Roedy Green

Below is a simple spam blocker for email addresses on webpages...but I don't
know how to change the color to yellow for the email link. Also, I'd like
the email address to be underlined. Any help here? THANKS!

First JavaScript is a completely different language from Java. You
would have better luck directing your queries to a JavaScript
Newsgroup.

See http://mindprod.com/jgloss/javascript.html

The basic idea of JavaScript is you compose HTML strings with markup.
e.g. <b> <span class="xxx">. So you get the effects you want using
HTML or CSS wrapped around the text you generate. See
http://mindprod.com/jgloss/htmlcheat.html
http://mindprod.com/jgloss/css.html
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Here is a point of no return after which warming becomes unstoppable
and we are probably going to sail right through it.
It is the point at which anthropogenic (human-caused) warming triggers
huge releases of carbon dioxide from warming oceans, or similar releases
of both carbon dioxide and methane from melting permafrost, or both.
Most climate scientists think that point lies not far beyond 2°C (4°F) C hotter."
~ Gwynne Dyer
 
C

Collon

Yea well I got answers from every group I posted to...so you can suck it
Thomas. Your reply was worse than me posting to a java group.


Thomas 'PointedEars' Lahn said:
Collon said:
Below is a simple spam blocker for email addresses on webpages... [...]

It is a user feedback blocker. And given your clueless From and
Newsgroups
headers, that is all to be said about it.


comp.lang.java removed, f'up2 c.l.js

PointedEars
 
C

Collon

Travor thank you very much. I had to change
<script type="text/javascript">
back to this <SCRIPT LANGUAGE="JavaScript"> to get it to work though.
Anyway, it works like I needed. Thanks!!
 
T

Trevor Lawrence

Collon said:
Travor thank you very much. I had to change
<script type="text/javascript">
back to this <SCRIPT LANGUAGE="JavaScript"> to get it to work though.
Anyway, it works like I needed. Thanks!!

Collon,
I am glad that it worked

But I can't undesrtand why you needed to make that change. <script
type="text/javascript"> is recommended, but I find that <script> also works
because type="text/javascript" is the default in most modern browsers (from
what I have read). But don't tell the purists here about that or you might
get a similar response from Thomas et al.
 
G

Gregor Kofler

that's right, you can sucks Thomas, you're cockhead..

Gregor



Thomas 'PointedEars' Lahn said:
Collon said:
Below is a simple spam blocker for email addresses on webpages... [...]

It is a user feedback blocker. And given your clueless From and
Newsgroups
headers, that is all to be said about it.


comp.lang.java removed, f'up2 c.l.js

PointedEars
 
D

Dan Evans

You can add a <span style=...></span>

Below is my test code. Because yellow does not show very well on white (the
default background colour), I changed it to black. <a> tags are underlined
automatically, but I did find that adding the text-decoration changed the
underline colour to yellow rather than the default, which was blue for me
Just FYI, the user can change the default background color and you
shouldn't count on links being underlined since a browser could print
them differently if it wasn't specified. It can be dangerous to rely
on defaults like this that just happen to be true if they're not
required by some spec or something.
<script type="text/javascript">
function jemail(user, domain, suffix){
document.write( '<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix
+ '"><span
style="background-color:black;color:yellow;text-decoration:underline;">' +
user + '@' + domain + '.' + suffix + '</span></a>');}

</script>
I don't see why you would add a <span> when you could just put the
style="..." attribute on the <a> tag.

<a href="..." style="background-color: black; color: yellow; text-
decoration: underline;">...</a>

Actually, I think the best method would use a CSS class and put the
definition in a CSS file.

<a href="..." class="email">...</a>

In the CSS:
a.email {
background-color: black;
color: yellow;
text-decoration: underline;
}

- Dan Evans
 
H

Hal Rosser

Collon said:
Below is a simple spam blocker for email addresses on webpages...but I
don't know how to change the color to yellow for the email link. Also, I'd
like the email address to be underlined. Any help here? THANKS!


<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var user;
var domain;
var suffix;
function jemail(user, domain, suffix){
document.write( '<a href="' + 'mailto:' + user + '@' + domain + '.' +
suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
}
//-->
// End -->
</script>


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
jemail("pay", "nothanks", "com");
// End -->
</script>
When writing your "a" tag, include a style attribute with the appropriate
styles in the tag .
style="color: yellow; text-decoration: underline;"
Ya gotta get used to using styles (css).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top