PDA

View Full Version : Hide Email Address In img src



dude9er
02-19-2007, 10:28 PM
I have an email address list that is dynamically genereated from an SQL Database. I want to write the address into a MAILTO: image using javascript, but can't figure out how to incorporate my ASP into the code.

I am using the JS here http://javascript.internet.com/page-details/spambot-countermeasure.html

Here is my code but it doesn't work:



'receive value from DB
<%= oRs.Fields("email") %>

'=========================

<script language="JavaScript"><!--

// hide script
<% Dim email as String
email= oRs.Fields("email")
if(email.IndexOf("@")>0){
%>
var sb_domain = "<%=email.Substring(email.IndexOf("@") + 1)%>";
var sb_user = "<%=email.Substring(0, (email.IndexOf("@") + 1))%>";
var sb_recipient = sb_user + sb_domain;
var sb_url = "mailto:" + sb_recipient;
document.write('<a href="'+sb_url+'"><img src="http://somesite.com/email1.jpg" border="0"/> </a>');
<%}%>
// --></script>



can someone help me write this, I getting loads of Microsoft VBScript errors. OR does anyone have a script that already functions?

Thanks!!!!

djr33
02-20-2007, 05:39 AM
This is silly. Using javascript to generate something means that the email is accessible to the user, just by looking at the source code.

If you really wanted to hide it, create the image dynamically using PHP (not sure if ASP has a similar option, though one might exist) and then write the text onto that image.
Just dynamically generating the SRC only creates javascript-dependance and doesn't really stop someone who wants to harvest the emails.
If you'd like, I can write a PHP script (sorry, I don't know ASP) that would harvest them from your pages to give you an example.

Hip_Hip_Array
03-01-2007, 03:26 PM
djr33 it's sounds like you may have the solution to my problem.

I am using a series of images on a page and I want to be able to hide the image source from a user if they view my source code.

Can I do this?

I don not want to hide / scramble my source code. I dont want to prevent right click or save images as.

It's just that a user logs into my site. once logged in it displays their picture. If a user views source code and copies the image source path they can paste it into the address bar and change the url slightly and it will then display someone elses picture.

eg <img src="http://www.site.com/folder1/folder2/$username.jpg"> in actual code, which becomes

<img src="http://www.site.com/folder1/folder2/mickeymouse.jpg"> when viewing source code, cut and paste to address bar

change to

http://www.site.com/folder1/folder2/bettyboop.jpg and they can then see betty boops picture.

so can I hide this somehow?

Many thanks

p.s Sorry for the post hijack.