Page 1 of 2

How to use javascript in articles?

Posted: Tue Jun 24, 2008 7:39 pm
by Markyboy
Hi,

I have a problem to show javascript or iframe codes in articles.
i am a little bit surprised that response is not really coming. It can't be that difficult as i excpect that i am not the only one who is using this type of codes? Can someone please inform me how i can display a banner that is using the following typ of code.

<script type="text/javascript">
var uri = 'http://impnl.tradedoubler.com/imp?type( ... a(1532223)' + new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
</script>

I run joomla 1.5.3
editor >> no editor enabled

Thanx

Dissapointed?

Posted: Wed Jun 25, 2008 8:53 am
by Markyboy
Although the topic has been read already 35 times i am rather surprised that no one of the joomla community is able to answer this,to my opinion, simple question, Simple meaning if you know something about coding ofcourse. I wonder if I have submitted this topic in the wrong section. Is there another section maybe where the coders are who know how to solve this issue??

Help would be very appreciated.

Thanx

Re: How to use javascript in articles?

Posted: Wed Jun 25, 2008 1:05 pm
by alepee
Hi Markyboy !

to use Javascript you can use JCE as WYSIWYG
this one allow javascript use into articles and it's free :)

Download plug-in, component and JCE Utilities on the website http://www.joomlacontenteditor.net/
(you have to register for downloading)

After installation go to Administrator and access Components > JCE Administrator > Configuration
and set Allow javascript to Yes :D

You can althought create users groups with specific rights. 8)

So past your script and enjoy !

Re: How to use javascript in articles?

Posted: Wed Jun 25, 2008 2:31 pm
by Markyboy
Hi Antoine,

Thanks for the information provided. I have installed the JCE component, plugin & utilities.
I have enabled the JCE editor in Global Configuration.
I have allow javascript set to "yes"

I have implemented the code by using the <> html icon
I updated the content file and saved.

Still no correct showing on the site?? I have no idear why? :(

It looks like this.
http://travel2.gr/index.php?option=com_ ... Itemid=216

The good news is that it doesn't mess up the codes anymore. ;)

Any other suggestions?

Thanks for your help.

Markyboy

Re: How to use javascript in articles?

Posted: Wed Jun 25, 2008 3:00 pm
by alepee
Ok, you should try to set Groups preferences and add your account. Maybe this overwrite your JCE configuration params.
You can access it via Components > JCE Administrator > Groups

If you are not sure for manipulation, you can create a new group and add your account.

I'm not sure this will work but it could be helpful :D

Keep me informed of issues

Re: How to use javascript in articles?

Posted: Wed Jun 25, 2008 5:37 pm
by Markyboy
Hi,

i tried to add a new user.. although i get the message that it is saved i also see the following error message
DB function failed with error number 1054
Unknown column 'a.name' in 'order clause' SQL=SELECT g.*, u.name AS editor FROM jos_jce_groups AS g LEFT JOIN jos_users AS u ON u.id = g.checked_out GROUP BY g.id ORDER BY a.name , g.ordering ASC LIMIT 0, 20
Going again to groups will give the same error message.

???

Markyboy

Re: How to use javascript in articles?

Posted: Thu Jun 26, 2008 7:18 am
by alepee
Wouah ! :eek:

never seen this yet ! I use JCE for a long time and groups function works well on my server.
Check on JCE forum, maybe there is a previous case
JCE Forum : http://www.joomlacontenteditor.net/inde ... &Itemid=63

Keep me informed :pop

Re: How to use javascript in articles?

Posted: Thu Jun 26, 2008 2:47 pm
by Markyboy
First a critical note:
I want to point out again that there is very little support from joomla coders around here. Many components, plugins etc. are not working properly or have conflicts in different surroundings and settings. As a joomla user this gets extremely frustrating, so some help or advice from the makers would be very much appreciated.

After pulling my hair out for 3 days i had made a small improvement for showing some javascript in the content.

I managed to show some javascript using joomlaFCK editor
To do this i had to disable the plugin content -embed
This is now the only way to see at least something.

http://travel2.gr/index.php?option=com_ ... &Itemid=81

But adding more than one script is messing up things again. It removes the content title and some other strange errors appear .

Anyone has an idear?


Marc

Re: How to use javascript in articles?

Posted: Sun Jun 29, 2008 9:05 pm
by diogoac
ha, good to know that :)

Re: How to use javascript in articles?

Posted: Thu Jul 03, 2008 3:11 pm
by keylin
From looking at your page, it's seems like you found a solution? Care to share it? I'm have the same problem :-[

Re: How to use javascript in articles?

Posted: Fri Aug 15, 2008 2:20 am
by browntek
JCE worked great for me but I accidentally skipped enabling it is as the wysiwyg editor at first and was having some problems of course. I know it was mentioned as a step on this forum but just in case someone else forgets that was my only problem.

Re: How to use javascript in articles?

Posted: Thu Feb 19, 2009 6:24 am
by drakeone69
Hi Alepee; without your assistance I would have never got the dang thing working lol ;)

but I have one question.

Do you know why it would in the JA_Purity template post the article that I inserted some javascript code into, why would it post it all the way over to the right hand side but ONLY in firefox? it's quite odd and I don't know why, it works fine in IE

http://www.ubetterbuy.com

Re: How to use javascript in articles?

Posted: Wed Mar 25, 2009 4:49 pm
by Azrael
Hi guys,

Do you know how I can use javascript but in modules? I have JCE and it doesn't work.

Re: How to use javascript in articles?

Posted: Thu Mar 26, 2009 2:59 am
by prateekshaweb
hi

try no editor.... it is simple, already installed and no side effects...it does work like a charm....

set the user editor to no editor... and switch back when done....

i know it is a crude solution...

sumeet

Re: How to use javascript in articles?

Posted: Mon Aug 17, 2009 2:24 am
by littlelizard
prateekshaweb wrote:hi

try no editor.... it is simple, already installed and no side effects...it does work like a charm....

set the user editor to no editor... and switch back when done....

i know it is a crude solution...

sumeet
Crude but very effect. Worked like a charm for me. Thanks!

Re: How to use javascript in articles?

Posted: Fri Aug 21, 2009 5:09 am
by always18
Hi guys,

I have better solution for this problem. No need to choose No WYSIWYG editor in global configuration of site. You can also write javascript in articles using default editor(TinyMCE 2.0).

Steps ->

Go to plugin manager & click on TinyMCE 2.0
Go to plugin parameters
select " never " to Code cleanup on save option & save it.
Now you can write your javascript in articles(joomla).

I hope it ll be useful for you all.

Regards,
Always18

Re: How to use javascript in articles?

Posted: Sat Sep 05, 2009 5:40 pm
by little_brain
Thank you, always18! I have had so much trouble with the editor and I didn't know there was an option to turn off the cleanup (which seems mostly to be a 'dirtyup' or a 'break it'). Even just having my line breaks remain is so lovely, thank you again!

Re: How to use javascript in articles?

Posted: Sun Sep 06, 2009 3:30 am
by prateekshaweb
yes..it is good...

but there is a plugin Sourcer...that allows you to add css and script code to your code...works like a charm and with all editors

Re: How to use javascript in articles?

Posted: Sun Sep 06, 2009 9:09 am
by little_brain
Thanks - I'll give that a try.

I actually found I had to switch to "No Editor" (set it for the user under User Manager) to get the script to work. But the "never cleanup" is such a help anyway.

Re: How to use javascript in articles?

Posted: Sun Sep 06, 2009 9:38 am
by little_brain
I've installed sourcerer, and it is enabled, but it doesn't seem to work. I have pasted in my code at the end of the article, and surrounded it by tags (I thought there should be a button in the editor, but there isn't)

{source}<script type = "text/javascript" src = "/wychwoodcats/templates/my_javascript/calculator_utilities.js"></script>
<script type = "text/javascript" src = "/wychwoodcats/templates/my_javascript/due_date.js"></script>{/source}

But when I save the HTML and then reopen, MCE has messed it up again:

<p>{source}<mce:script type="text/javascript" src="/wychwoodcats/templates/my_javascript/calculator_utilities.js"></mce:script>
<mce:script type="text/javascript" src="/wychwoodcats/templates/my_javascript/due_date.js"></mce:script>{/source}</p>

Any ideas, anybody?

Re: How to use javascript in articles?

Posted: Sun Sep 06, 2009 10:02 am
by little_brain
I think I've got it working now - the button is at the bottom of the screen not in the toolbar. And in the Sourcerer editor, I turned off "colorize tags". Thanks.

Re: How to use javascript in articles?

Posted: Sun Sep 06, 2009 11:15 am
by prateekshaweb
hi.. little brain...

there is a module called "custom code"... it is similar to Custom html but that module allows all script and css also php code....

it is comes very handy ...try it

Re: How to use javascript in articles?

Posted: Mon Sep 07, 2009 12:21 pm
by little_brain
Does anybody know a way to stop Sourcerer from inserting <br> tags at the end of lines? It's a right pain because it invalidates the XHTML!

Re: How to use javascript in articles?

Posted: Tue Sep 22, 2009 4:50 pm
by vispi
hi all
i am a joomla newbie, so sorry for noobish questions..

i want to create a simple website with a prominent download button in the front page.
i am able to use a javascript to detect the visitors os and download the coressponding file, if i use "text" as the clickable entity..
however if i try to use an image instead, it doesnt show the image using document.write();

please point out some way to do it.
it would be nice if i am able to create a large and prominent button with the required javascript actind when it is pressed.
how can i use sourcerer for this?
thanx in advance

Re: How to use javascript in articles?

Posted: Wed Sep 23, 2009 8:35 am
by divengrabber
Using java script is depend on there site page. First check that and then find out what working for them.

Re: How to use javascript in articles?

Posted: Sun Nov 15, 2009 12:03 am
by Ladas
The tip about JCE configuration works like a charm! Cheers! I used it on http://www.sailingchannel.gr to add the facebook badge on the side

Re: How to use javascript in articles?

Posted: Wed Dec 02, 2009 3:46 am
by melongal
You may try to solve this problem via reading this article:
http://docs.joomla.org/Why_does_some_HT ... n_1.5.8%3F

I find this really useful cause it solved my problem of using javascript in articles. :)

Re: How to use javascript in articles?

Posted: Sat Feb 20, 2010 12:16 am
by click2grow
I'm trying to add 2 flash videos to a page via java script. When I put 1 on the page it works just fine. When I put both on the page only the first one alphabetically plays regardless of which one is first on the page. I get the same result inserting through JCE and Sourcer.

Here is the page: http://www.click2grow.com/video-marketing.html

/media/video/MassageByJJ.FLV is the first one on the page, but when I put both java script codes in the same article only this one Plays:

/media/video/bellwether.FLV

Right now both JS code has been inserted using sourcer and I get the same problem. I contacted my hosting company and they said I'm missing a plugin for joomla to make them both run. That's when I tried sourcer and I'm still stuck.

Re: How to use javascript in articles?

Posted: Sat Feb 20, 2010 12:17 am
by mssmtih13
vispi wrote:hi all
i am a joomla newbie, so sorry for noobish questions..

i want to create a simple website with a prominent download button in the front page.
i am able to use a javascript to detect the visitors os and download the coressponding file, if i use "text" as the clickable entity..
however if i try to use an image instead, it doesnt show the image using document.write();

please point out some way to do it.
it would be nice if i am able to create a large and prominent button with the required javascript actind when it is pressed.
how can i use sourcerer for this?
thanx in advance
Vispi...the document.write method is usually only used during the page load event of a web page. I beleive that if you are putting javascript in the article body then the page load event has already finished by the time it runs your code. A more tradititional way of dynamically adding elements to a page would be:

Code: Select all

  var el = document.createElement('input');
  el.type = 'button';
  el.value = 'Download';
and then give it an onclick event.

Code: Select all

  el.onclick = myFunction();
The above code only creates your element...to add the element to your page you would need to find the element you want to add it after and:

Code: Select all

var afterMe = document.getElementById(someId);
afterMe.appendChild(el);
I haven't tested this in Joomla! but it should work better for dynamic elements.

Re: How to use javascript in articles?

Posted: Sat Feb 20, 2010 12:21 am
by mssmtih13
click2grow wrote:I'm trying to add 2 flash videos to a page via java script. When I put 1 on the page it works just fine. When I put both on the page only the first one alphabetically plays regardless of which one is first on the page. I get the same result inserting through JCE and Sourcer.

Here is the page: http://www.click2grow.com/video-marketing.html

/media/video/MassageByJJ.FLV is the first one on the page, but when I put both java script codes in the same article only this one Plays:

/media/video/bellwether.FLV

Right now both JS code has been inserted using sourcer and I get the same problem. I contacted my hosting company and they said I'm missing a plugin for joomla to make them both run. That's when I tried sourcer and I'm still stuck.
Hey click2grow...can you post the javascript code your using (of course removing any identifiable information from it first)