Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

WaterMark Image with javascript

Posted on 2008-06-18
5
Medium Priority
?
1,528 Views
Last Modified: 2012-06-21
Hi all,
I have web application developed by asp.net 2.0 (VS 2005), I have a page displaying a table with thefollowing information: Car Model ,Description and Image.
In the Database i stored image as a path. and i use a datalist control to display these information as a table.

Challenge:
When a car is sold, then i want to display a stamp such as [SOLD] to be displayed over the image.
i tried many ways, such as javascript [attahed code snippet]. but the problem is:
When i minimize the browser the [SOLD]  displayed in the same position that because position:absolute.

<ItemTemplate>
        <br />
        <table border="1" style="width: 100px; height: 100px">
         <tr>
         <td style="width: 100px">
        <asp:Image ID="Image1" runat="server" Height="94px" ImageUrl='<%# Eval("img") %>'
        Width="134px" />
       <script type="text/javascript" language="javascript">
       var top;
       var left;
      top=document.getElementById("DataList1_ctl00_Image1").style.top;
      left=450;
     document.write("<font color='red'><div id='d1' style='left:"+left+"px; width: 100px; position: absolute; top:"+top+"px; height: 100px;font-size:50px;font-color:red'>[SOLD]</div></font>")
          </script> 
     </td>
    </tr>
</table>
<br />
</ItemTemplate>

Open in new window

0
Comment
Question by:Mremawi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 10

Accepted Solution

by:
bluefezteam earned 800 total points
ID: 21811892
You should use CSS for this - i did it for a property site.

<div class="imageHolder"><img src="car.jpg"/><img src="sold.jpg" class="sold"/></div>

.imageHolder {
display:block;
width:200px;
height:100px;
position:relative;
}
.imageHolder .sold {
position:absolute;
bottom:0;
left:0;
}

This will then holder a sold sign at the base of the image so you can still see the item on sale/sold but there's a sold image over it.

in action or a variation of it can be seen here

http://www.jhilditch.com/buy.html
0
 
LVL 10

Expert Comment

by:bluefezteam
ID: 21811895
If possible can you move this item to CSS ? it is a CSS related issue.
0
 
LVL 1

Author Comment

by:Mremawi
ID: 21837141
Dear bluefezteam:

thank you very much for your solution, but can I make the image sold in middle of car.jpg image?
0
 
LVL 10

Expert Comment

by:bluefezteam
ID: 21840629
yes - instead of bottom:0; you just need to know the height of your JPEG and divide that by 2, then remove the height of the sold.jpg divided by 2.

Eg

the car graphic is 100px high - its mid point is 50px.
The sold image that sits on the top is 30px - its mid point is 15px.

this means to get sold.jpg to appear over the middle of the the car.jpg you pocition it from TOP or BOTTOM by 50-15 = 35px.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question