Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 868 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add javascript to joomla module?

#1
Hi I have problem with adding javascript into a joomla module..I've found some solution, but it's not working..

$document = &JFactory::getDocument();
$document->addScript("/career.js");

These two lines I have in my module, but the script isn't in rendered site..
The file is in root of my web (for test purposes only).

Thanks for your help
Reply

#2
check the view source .

copy paste the path of the career.js as browser url and try to access it.

Change the path as needed.

. ./ ../
Reply

#3
You can Use following extension (works both 1.5 and 1.6) to include custom javascript or HTML easily.

[To see links please register here]


Also when you use directly may use full path like this (change the path of your .JS)

<?php
$document = &JFactory::getDocument();
$document->addScript( '/media/system/js/sample.js' );
?>
Reply

#4
So only workaround which works for me is to add this js to template of my site..But its really awful solution, since I only need it in one article/module
Reply

#5
You could also use the joomla php module

[To see links please register here]

or maybe you found a module that better fits your needs at:

[To see links please register here]

Reply

#6
Ouch..The main problem is, that I am loading the page containing custom module with javascript is loaded via ajax..And all the plugins seems to be adding the js code into head and I only replace some elements into body of my page.
exist some solution to this problem?I know I can have all the js logic into one file, but I am not sure it is good way. Is somehow possible to include js directly to module?So that the script tag will be within my document body and correctly included (i am not sure the code will be fired??)

Thanks
Reply

#7
Try this, it's working perfectly.

$document = &JFactory::getDocument();
$document->addScript('modules'.DS.'MOD_YOURMODULENAME'.DS.'javascript.js');
Reply

#8
Make sure that you have this

<jdoc:include type="head" />

after head tag in template index.php
Reply

#9
For all those who are landing on this page at a much later date, and looking for solution in Joomla 3.x

You can include a module of type "Custom HTML Advanced" which will NOT filter out any script or style tags.
You can use it on any of the pages you want.

Hope this helps you :)
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through