0

i have a javascript and php code that makes an email address hard for bots to find. i have it implemented on one site thats very basic and it works perfect, however on this other site with many more elements—something seems to go awry and it wont work.

the javascript adds in the mailto: and @ functions

in the php, the elements are called in and the javascript runs to complete the function when you click on it——making it like a regular mailto: function.

is there something i'm missing in terms of perhaps DOM or global elements or something?

i have this script being called in my header.php:

<script type="text/javascript" src="javascript/scripts.js"></script>

scripts.js:

function blind(name,domain) {
        str = "mailto:" + name + "@" + domain;
        window.location = str;
        }

emailgen.php:

function showContacts()
{
global $debe;
    $return ="";
    $return .="
    <div>";
    $contactitems = $debe->runSql("SELECT * FROM contacts ORDER BY imp");

    for($i=0; $i<count($contactitems); $i++)
    {
            $parts = explode('@', substr($contactitems[$i][3], $pos + 0));

            $return .="
            <p><a href=\"" . $contactitems[$i][2] . "\">" . $contactitems[$i][1] . "</a><br />
            <a href=\"javascript:blind('" . $parts[0] . ",'" . $parts[1] . "')\">" .  $parts[0] . "@" . $parts[1] . "</a><br />
            </p>";  
    }

    return $return;
}

when i view the source, it seems to show up okay but for some reason the mailto: isn't calling.

viewsource of emailgen.php:

<a href="javascript:blind('name,'email.com')">[email protected]</a><br />

1 Answer 1

3

Add a single quote after $parts[0] . ":

<a href=\"javascript:blind('" . $parts[0] . "','" . $parts[1] . "')\">" .  $parts[0] . "@" . $parts[1] . "</a><br />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.