How to use javascript in articles?

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Markyboy
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Thu Jun 12, 2008 11:21 am

How to use javascript in articles?

Post by Markyboy » Tue Jun 24, 2008 7:39 pm

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

Markyboy
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Thu Jun 12, 2008 11:21 am

Dissapointed?

Post by Markyboy » Wed Jun 25, 2008 8:53 am

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

alepee
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Jan 10, 2008 9:07 am

Re: How to use javascript in articles?

Post by alepee » Wed Jun 25, 2008 1:05 pm

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 !

Markyboy
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Thu Jun 12, 2008 11:21 am

Re: How to use javascript in articles?

Post by Markyboy » Wed Jun 25, 2008 2:31 pm

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

alepee
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Jan 10, 2008 9:07 am

Re: How to use javascript in articles?

Post by alepee » Wed Jun 25, 2008 3:00 pm

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

Markyboy
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Thu Jun 12, 2008 11:21 am

Re: How to use javascript in articles?

Post by Markyboy » Wed Jun 25, 2008 5:37 pm

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

alepee
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Jan 10, 2008 9:07 am

Re: How to use javascript in articles?

Post by alepee » Thu Jun 26, 2008 7:18 am

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

Markyboy
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Thu Jun 12, 2008 11:21 am

Re: How to use javascript in articles?

Post by Markyboy » Thu Jun 26, 2008 2:47 pm

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

diogoac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 111
Joined: Sat Jun 14, 2008 11:24 pm

Re: How to use javascript in articles?

Post by diogoac » Sun Jun 29, 2008 9:05 pm

ha, good to know that :)

keylin
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Sun Jun 08, 2008 5:18 pm

Re: How to use javascript in articles?

Post by keylin » Thu Jul 03, 2008 3:11 pm

From looking at your page, it's seems like you found a solution? Care to share it? I'm have the same problem :-[

browntek
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Aug 15, 2008 2:17 am

Re: How to use javascript in articles?

Post by browntek » Fri Aug 15, 2008 2:20 am

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.

User avatar
drakeone69
Joomla! Intern
Joomla! Intern
Posts: 52
Joined: Wed Feb 18, 2009 2:50 pm
Location: Toronto
Contact:

Re: How to use javascript in articles?

Post by drakeone69 » Thu Feb 19, 2009 6:24 am

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

Azrael
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Aug 02, 2006 1:37 am

Re: How to use javascript in articles?

Post by Azrael » Wed Mar 25, 2009 4:49 pm

Hi guys,

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

prateekshaweb
Joomla! Explorer
Joomla! Explorer
Posts: 331
Joined: Mon Aug 04, 2008 8:00 am
Location: India
Contact:

Re: How to use javascript in articles?

Post by prateekshaweb » Thu Mar 26, 2009 2:59 am

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
Sumeet Shroff
PSD to Joomla, Joomla Custom Template Design and Virtuemart Shopping Cart
http://www.prateeksha.com http://www.joomlawebsitedesigners.com

littlelizard
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Wed Oct 25, 2006 2:34 am

Re: How to use javascript in articles?

Post by littlelizard » Mon Aug 17, 2009 2:24 am

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!

always18
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Aug 21, 2009 5:03 am

Re: How to use javascript in articles?

Post by always18 » Fri Aug 21, 2009 5:09 am

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

little_brain
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Fri Apr 03, 2009 9:33 am

Re: How to use javascript in articles?

Post by little_brain » Sat Sep 05, 2009 5:40 pm

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!

prateekshaweb
Joomla! Explorer
Joomla! Explorer
Posts: 331
Joined: Mon Aug 04, 2008 8:00 am
Location: India
Contact:

Re: How to use javascript in articles?

Post by prateekshaweb » Sun Sep 06, 2009 3:30 am

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
Sumeet Shroff
PSD to Joomla, Joomla Custom Template Design and Virtuemart Shopping Cart
http://www.prateeksha.com http://www.joomlawebsitedesigners.com

little_brain
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Fri Apr 03, 2009 9:33 am

Re: How to use javascript in articles?

Post by little_brain » Sun Sep 06, 2009 9:09 am

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.

little_brain
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Fri Apr 03, 2009 9:33 am

Re: How to use javascript in articles?

Post by little_brain » Sun Sep 06, 2009 9:38 am

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?

little_brain
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Fri Apr 03, 2009 9:33 am

Re: How to use javascript in articles?

Post by little_brain » Sun Sep 06, 2009 10:02 am

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.

prateekshaweb
Joomla! Explorer
Joomla! Explorer
Posts: 331
Joined: Mon Aug 04, 2008 8:00 am
Location: India
Contact:

Re: How to use javascript in articles?

Post by prateekshaweb » Sun Sep 06, 2009 11:15 am

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
Sumeet Shroff
PSD to Joomla, Joomla Custom Template Design and Virtuemart Shopping Cart
http://www.prateeksha.com http://www.joomlawebsitedesigners.com

little_brain
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Fri Apr 03, 2009 9:33 am

Re: How to use javascript in articles?

Post by little_brain » Mon Sep 07, 2009 12:21 pm

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!

vispi
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Sep 22, 2009 2:50 pm

Re: How to use javascript in articles?

Post by vispi » Tue Sep 22, 2009 4:50 pm

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

divengrabber
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Aug 07, 2009 12:12 pm

Re: How to use javascript in articles?

Post by divengrabber » Wed Sep 23, 2009 8:35 am

Using java script is depend on there site page. First check that and then find out what working for them.

Ladas
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun Nov 15, 2009 12:01 am
Contact:

Re: How to use javascript in articles?

Post by Ladas » Sun Nov 15, 2009 12:03 am

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

melongal
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Jul 30, 2009 11:02 am

Re: How to use javascript in articles?

Post by melongal » Wed Dec 02, 2009 3:46 am

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. :)

click2grow
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat Feb 20, 2010 12:15 am

Re: How to use javascript in articles?

Post by click2grow » Sat Feb 20, 2010 12:16 am

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.

mssmtih13
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Feb 19, 2010 11:59 pm

Re: How to use javascript in articles?

Post by mssmtih13 » Sat Feb 20, 2010 12:17 am

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.

mssmtih13
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Feb 19, 2010 11:59 pm

Re: How to use javascript in articles?

Post by mssmtih13 » Sat Feb 20, 2010 12:21 am

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)


Locked

Return to “Joomla! 1.5 Coding”