Forums

External js file won't load

johnoathome 15 Jan, 2015
Hi All,

My first post in this forum. I'm having trouble getting an external javascript file to load in CF5. I've inserted a Load Javascript element in the setup/onload event and put the path to the file in the JS Files box. I've tried all sorts of formats including relative path and full path from the server root but no matter what I do I can't get anything to fire. Javascript works fine if I include it directly in the element.

I took it right back to basics and put a simple alert in the external file and still nothing. So I ran up a brand new Joomla instance just with CF5 and still no good.

Any tips on what might be going on here would be greatly appreciated.

John
Max_admin 16 Jan, 2015
Hi John,

Please try to put the full file path, starting from "http", does that work ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 16 Jan, 2015
Hi John,

I had some problems with the JS Files box so stopped using it. In early versions it made some assumptions about the path that where hard to over-ride - though they may have been fixed now.

In Joomla! you can always use the Joomla! code in a Custom Code action (or possibly in the Load JS script box):
<?php
$jdoc =& JFactory::getDocument();
$jdoc->addScript('file_url');
?>
Note: don't use $doc because CFv5 uses that for something else.

Bob
johnoathome 16 Jan, 2015
Hi Max and Bob,

Well in fact it does work with the URL...

I had previously tried that, but I was using filezilla to copy the file path to the clipboard. Filezilla and Joomla were referencing the same host by different names i.e. www1.domainname.com vs www.domainname.com. I just didn't pick up on the difference - too many late nights and too many servers!

In the light of day, looking at the page source made it clear what was going on.

Essentially, if you don't use a http URL, the path to the script is set to /libraries/cegcore/path-you-entered/file-you-entered.js. This will work provided you don't put a leading slash in front of the path (and of course provided the file and directory structure you entered exist under /libraries/cegcore).

BTW, great product. Best thing out there by far.

Thanks, and thanks for getting back.

Regards
John
GreyHead 16 Jan, 2015
Hi John,

Thanks for the update :-)

Bob
This topic is locked and no more replies can be posted.