Hi
Yes, this isnt' a forum about Javascript, but I don't know
where else to go.
I'm building a site and I have a piece of javascript to
display a random image on the page.
Here it is
http://www.rachel-martin.com/nf/013index.html
That's all working well, however, I'd like to apply a style
to the image (just a black border round the edge).
Does anybody know how to do this, or where there is a source
for it online?
I've heard something about 'style objects' but don't know
anymore.
Thanks very much in advance.
Racheljavascript style
%26gt; Does anybody know how to do this, or where there is a
source for it
%26gt; online?
%26gt; I've heard something about 'style objects' but don't
know anymore.
%26lt;img src=''yourimage'' style=''border: 1px solid black;''
/%26gt;
-Darrel
javascript style
Change this in your Javascript -
document.write('%26lt;img
src='''+theImages[whichImage]+'''%26gt;');
to this -
document.write('%26lt;img src='''+theImages[whichImage]+'''
style=''border: 1px
solid #000000''%26gt;');
--
Shane H
shane@NOSPAMavenuedesigners.com
http://www.avenuedesigners.com
=============================================
Back for 2007, close-up magic:
http://deceptivemagic.com
Web dev articles, photography, and more:
http://sourtea.com
=============================================
Proud GAWDS member
http://www.gawds.org/showmember.php?memberid=1495
Delivering accessible websites to all ...
=============================================
''martianarm'' %26lt;webforumsuser@macromedia.com%26gt; wrote in
message
news:euj6jb$kpu$1@forums.macromedia.com...
%26gt; Hi
%26gt; Yes, this isnt' a forum about Javascript, but I don't
know where else to
%26gt; go.
%26gt; I'm building a site and I have a piece of javascript to
display a random
%26gt; image
%26gt; on the page.
%26gt; Here it is
http://www.rachel-martin.com/nf/013index.html
%26gt; That's all working well, however, I'd like to apply a
style to the image
%26gt; (just
%26gt; a black border round the edge).
%26gt;
%26gt; Does anybody know how to do this, or where there is a
source for it
%26gt; online?
%26gt; I've heard something about 'style objects' but don't
know anymore.
%26gt;
%26gt; Thanks very much in advance.
%26gt; Rachel
%26gt;
Thanks for the reply, but I need something in Javascript, as
it needs to apply to the javascript function.
On 30 Mar 2007 in macromedia.dreamweaver, martianarm wrote:
%26gt; Thanks for the reply, but I need something in
Javascript, as it
%26gt; needs to apply to the javascript function.
Actually, it doesn't. The image written by the script is
contained
within a div with an id, so you can target it using CSS:
#content_centre_left img {
border : 3px dotted lime;
}
Alter to suit.
--
Joe Makowiec
http://makowiec.net/
Email:
http://makowiec.net/contact.php
%26gt; Thanks for the reply, but I need something in
Javascript, as it needs to
%26gt; apply to the javascript function.
CSS doesn't apply styles to javascript. It applies styles to
HTML elements.
Your javascript is producing an HTML element (the A tag) and,
as such, the
style needs to apply to the tag, not the javascript. Both Joe
and Shane
provide some more details for you.
-Darrel
Wow - I'm so impressed that people replied and so quickly.
Shane - thanks so much for that, it works perfectly.
Thanks for the other replies too - yes, I can see now from
what you've written that you could also do it without Javascript.
All the best
Rachel
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment