Solved

WaterMark Image with javascript

Posted on 2008-06-18
5
1,525 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 200 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

717 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