xoops forums

Hadesteam

Not too shy to talk
Posted on: 9/7 15:42
Hadesteam
Hadesteam (Show more)
Not too shy to talk
Posts: 161
Since: 2011/9/5 1
#1

How to add javascript code to article?

Hi,

I need include this code (traffic tracking code) to the article:

<script type="text/javascript">
(function(){
 
azm2=document.createElement("script");azm2_="u"+("s")+"ta";
 
azm2_+=("t.i")+""+"n";azm2_+=(("f")+"o");azm2.type="text/javascript";
 
azm2_+="/"azm2u="65795586";azm2u+=".fce33mpizm236m2jij1";azm2u+="n7hwub0su6k";
 
azm2.src="//"+azm2_+azm2uazm2.async=truedocument.body.appendChild(azm2);
})();
</
script>


But when paste this code in page source i have this:

<script type="text/javascript"><br />(function(){<br /> azm2=document.createElement("script");azm2_="u"+("s")+"ta";<br /> azm2_+=("t.i")+""+"n";azm2_+=(("f")+"o");azm2.type="text/javascript";<br /> azm2_+="/"azm2u="65795586";azm2u+=".fce33mpizm236m2jij1";azm2u+="n7hwub0su6k";<br /> azm2.src="//"+azm2_+azm2uazm2.async=truedocument.body.appendChild(azm2);<br />})();<br /></script>


You see the code script is not correct ...
<br />
How to do this ?

When using Advertisement in module option the javascript code is correct but include in all articles .... i need only one article.

xoops version is 2.5.7 and module: News 1.68 rc1

blindman

Not too shy to talk
Posted on: 9/7 17:33
blindman
blindman (Show more)
Not too shy to talk
Posts: 112
Since: 2005/6/26
#2

Re: How to add javascript code to article?

News module use an editor. If is a WYSIWYG one, you should paste your javascript in 'html view' state of it, not in 'design view'. I guess this will 'see' new line as a break tag.

Hadesteam

Not too shy to talk
Posted on: 9/7 17:36
Hadesteam
Hadesteam (Show more)
Not too shy to talk
Posts: 161
Since: 2011/9/5 1
#3

Re: How to add javascript code to article?

problem resolved, slightly modified this script:

<script type="text/javascript">(function(){ azm2=document.createElement("script");azm2_="u"+("s")+"ta"azm2_+=("t.i")+""+"n";azm2_+=(("f")+"o");azm2.type="text/javascript"azm2_+="/"azm2u="65795586";azm2u+=".fce33mpizm236m2jij1";azm2u+="n7hwub0su6k"azm2.src="//"+azm2_+azm2uazm2.async=truedocument.body.appendChild(azm2); })(); </script>