Jump to content

This script shows undefined in my rendered page. Please help ! :)


med267

Recommended Posts

Hi *

 

Any help with this would be a godsend.

The script scrambles my email address(prevent spam harvester), but prints it the correct readable way when the page is viewed.

 

My problem is I get undefined showing up in my page just before declaring OT="";

 

It is driving me crazy as I dont know much javascript. I just tried to repurpose another script found elsewhere.

 

Any help or pointers getting rid of that undefined showing up, but still outputting my readable email in the document.write would be really appreciated

 

<li><span id='mEncEmail1'>(JavaScript must be enabled to view this email address)</span><script type="text/javascript">

//<![CDATA[

 

ML="dgotns/c@=f:eulwaimjp. \"h>r<";

MI="K@FHJ<:9GB@A>32;C<::E1=53@:552481B@A>E72BGI?<00A41587=DA05?<00A41E72BK6@I";

OT="";

for(j=0;j<MI.length;j++){

OT+=ML.charAt(MI.charCodeAt(j)-48);

}

 

document.getElementById('mEncEmail1').innerHTML = document.write(OT);

//]]>

</script></li>

Link to comment
Share on other sites

Thank you for your reply. I understand a little about what what you are saying escaping the quote

and leaving the dangling h>r<

 

but doesnt the quote after r<" close it even though the previous " is escaped?

 

Still not sure how to get it assigned to the correct value & output it to the document.write

without the undefined showing up on the page before the document.write happens.

 

I have tried escaping &  trying extra double quotes, but my inexperience definitely shows itself at every attempt.

 

If you or anyone has anymore insight into this it would be really helpful.

 

ML="dgotns/c@=[f:eulwaimjp. \"h>r<";
MI="K@FHJ<:9GB@A>32;C<::E1=53@:552481B@A>E72BGI?<00A41587=DA05?<00A41E72BK6@I";

Link to comment
Share on other sites

Removing the document.write worked. Thank you very much. Now i am trying to wrap my head around why it worked as compared to the document.write.

 

Any explanation would be great. I guess I need to find a way to echo the output on a per line basis.

 

Thanks again for showing me, until I understand it better.

 

Have a great day.

Link to comment
Share on other sites

document.write() method does not return a value. It outputs text to the page. That's it.

 

For example -

function write (arg) {
     document.body.innerHTML = arg;
}

var e = write('foo');

e doesn't contain a value because the function doesn't return a value. It's like how document.write() doesn't return any values. It just does something to the screen.

 

If you want to write some undefined value, it complains. You're just storing text into an element, so you don't need document.write(). In fact, it didn't make sense. What you had before is saying you want to store the value of the output of OT (from document.write) to inside the element mEncEmail. Of course that makes no sense. You want it to say - store the value of OT inside the element mEncEmail.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.