Putting text over an image

ggv
ggv used Ask the Experts™
on
In order to save downloading time I would like to have one button image and then be able to programmatically put a number of different texts on the same image. I read, Nescape understands the LAYER tag, which might be used to accomplish this task. However I am looking to have a universal code that will run also on IE. Would be grateful for any hints how to do that.

ggv
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
try <div class=myimage>text</div>
netscape suports it.. all major browsers suports it

add style
.myimage {
 bacground: ...
 color: ....
...
}

Commented:
<style> .myimage { background: url(img/my.gif); } </style>

...to be more precisely and for points split ;))
also consider adding width: 100px; height: 200 px; to style above in order to match image size
ggv

Author

Commented:
Makc,  are you saying that if I add width and height then my image should be accordingly resized? Doesn't seem so if I try with jpeg files.

ggv
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Commented:
no. I am just saying you should set width/height for <div> to match image size, or it will look cropped, I think.

Commented:
also, overflow:hidden; will help to avoid text overflow...
hi ggv,
try this:
==================================

<script>
function setText(ntext)
{
      var cont = document.getElementById("sometext")
      cont.innerHTML=ntext;
}
</script>


<table background=http://www.experts-exchange.com/images/logoWhiteSmall.gif width=218 cellspacing=0 cellpadding=0 border=0>
      <td height=35 valign=bottom id=sometext>some text</td>
</table>

<a href=javascript:void(setText("Athens")) class=text>Add text 1</a><br>
<a href=javascript:void(setText("Berlin")) class=text>Add text 2</a><br>
<a href=javascript:void(setText("Paris")) class=text>Add text 3</a><br>

Commented:
if you have php on your server, i have another solution that would solve the problem much easier.
ggv

Author

Commented:
No, I do not have php unfortunately. I'll have to use devic's proposal.

Thanks a lot.

ggv

Commented:
why devic's ? why2liz proposed essentially same thing... :-O

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial