Search

Hello,

I am desperately trying to get this piece of Javascript code into my Symphony site:

<script type="text/javascript">
    document.write("<n uers="znvygb:xvpx@vaprcgvba.pbz" ery="absbyybj">Fraq n zrffntr</n>".replace(/[a-zA-Z]/g, 
function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);}));
&lt;/script>

It’s just an obfuscated email address but I can’t get it to work even after reading a number of threads on this forum.

I’ve tried various combinations of <![CDATA[ and ]]> and <xsl:comment> and </xsl:comment> to wrap the code but it’s still not working.

Can anybody help?

Does this work?: http://gist.github.com/565083

It worked for me, even with the output method set to xml.

I guess that you probably won’t get this to work if you use “xml” as your XSL output method. (It would be rather easy using the “text” output method.)

Why don’t you simply put it in an external file?

&lt;script type="text/javascript" src="email.js">

BTW: The JavaScript code produces an error in Safari’s console. It just doesn’t work, even if it is sucessfully loaded from an external file.

This works:

&lt;script type="text/javascript">
    <xsl:comment>
    alert('Inline Javascript');
//</xsl:comment>
&lt;/script>

But this doesn’t:

&lt;script type="text/javascript">
    <xsl:comment>
    document.write("<n uers="znvygb:xvpx@vaprcgvba.pbz" ery="absbyybj">Fraq n zrffntr</n>".replace(/[a-zA-Z]/g,
            function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);}));
//</xsl:comment>
&lt;/script>

It throws an error when I try to save the page.

@michael: How exactly would you import the Javascript if you placed it in an external file?

Does this work?: http://gist.github.com/565197

If so, its because you had two sets of double quotes, I have changed the first set to single quotes. This should solve the problem.

If not…

you are doing: document.write(“<n uers=” < see, you are closing here quotes. Use ‘single’ quotes inside.

@michael: How exactly would you import the Javascript if you placed it in an external file?

Like this:

&lt;script type="text/javascript" src="{$root}/workspace/assets/js/email.js">&lt;/script>

XSLT is no liking the JavaScript, it disagrees with the <=, thinking its a tag. Your JS works out of Symphony but not inside it (due to XSLT). I will see if I can find a work around.

Either that or you could just do what @michael-e says and put the JS in a external file, infact this is properly preferred.

Ok, this appears to work: http://gist.github.com/565224 Can you try it out.

I have just replaced the < with its characeter code &#60;, in line 4.

It is not ideal, but it should work.

Edit: Just tried something I save here, you could also solve the problem by wrapping the javascript in <![CDATA[ and ]]>. Although I am sure you did not want all this info.

Thanks for your help everybody.

I am using this code now:

&lt;script type="text/javascript">
    <xsl:comment>
        Rot13.write('<n uers="znvygb:fpbggl@lnat.vq.nh">fpbggl@lnat.vq.nh</n>');
    </xsl:comment>
&lt;/script>

This code works, at least partially. It doesn’t even matter if I use single or double quotes. Most of the action is happening in an external rot13.js file, referenced through the head of my site.

However, what puzzles me is that it doesn’t return a mailto-link (as it should do), but rather a simple plain text version of the email address.

It’s a progress, but what I really need is the entire mailto-link.

Can anybody tell me what I’m missing here?

OK, no matter what I do, I can’t get this to work in my version of Symphony.

I have found a solution to my problem though, and created this new thread.

Thanks again for your help, guys.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details