diff --git a/libraries/cms/html/behavior.php b/libraries/cms/html/behavior.php
index 7d1d275ed44cc..cb92ca6399425 100644
--- a/libraries/cms/html/behavior.php
+++ b/libraries/cms/html/behavior.php
@@ -88,6 +88,10 @@ public static function core()
}
JHtml::_('script', 'system/core.js', array('version' => 'auto', 'relative' => true));
+
+ // Add core and base uri paths so javascript scripts can use them.
+ JFactory::getDocument()->addScriptOptions('system.paths', array('root' => JUri::root(true), 'base' => JUri::base(true)));
+
static::$loaded[__METHOD__] = true;
return;
diff --git a/media/system/js/keepalive-uncompressed.js b/media/system/js/keepalive-uncompressed.js
index 12dc01d22b677..8b9cdcd7f4da4 100644
--- a/media/system/js/keepalive-uncompressed.js
+++ b/media/system/js/keepalive-uncompressed.js
@@ -17,12 +17,20 @@
document.addEventListener('DOMContentLoaded', function() {
var keepaliveOptions = Joomla.getOptions('system.keepalive'),
- keepaliveUri = keepaliveOptions.uri ? keepaliveOptions.uri.replace(/&/g, '&') : window.location.pathname,
- keepaliveInterval = keepaliveOptions.interval ? keepaliveOptions.interval : 45 * 1000;
+ keepaliveUri = keepaliveOptions && keepaliveOptions.uri ? keepaliveOptions.uri.replace(/&/g, '&') : '',
+ keepaliveInterval = keepaliveOptions && keepaliveOptions.interval ? keepaliveOptions.interval : 45 * 1000;
+
+ // Fallback in case no keepalive uri was found.
+ if (keepaliveUri === '')
+ {
+ var systemPaths = Joomla.getOptions('system.paths');
+
+ keepaliveUri = (systemPaths ? systemPaths.root + '/index.php' : window.location.pathname) + '?option=com_ajax&format=json';
+ }
window.setInterval(function() {
Joomla.request({
- url: keepaliveUri,
+ url: keepaliveUri,
onSuccess: function(response, xhr)
{
// Do nothing
diff --git a/media/system/js/keepalive.js b/media/system/js/keepalive.js
index 568cf932b9482..ec2cb13e47f38 100644
--- a/media/system/js/keepalive.js
+++ b/media/system/js/keepalive.js
@@ -1 +1 @@
-!function(){"use strict";document.addEventListener("DOMContentLoaded",function(){var n=Joomla.getOptions("system.keepalive"),e=n.uri?n.uri.replace(/&/g,"&"):window.location.pathname,o=n.interval?n.interval:45e3;window.setInterval(function(){Joomla.request({url:e,onSuccess:function(){},onError:function(){}})},o)})}(window,document,Joomla);
+!function(){"use strict";document.addEventListener("DOMContentLoaded",function(){var o=Joomla.getOptions("system.keepalive"),n=o&&o.uri?o.uri.replace(/&/g,"&"):"",t=o&&o.interval?o.interval:45e3;if(""===n){var e=Joomla.getOptions("system.paths");n=(e?e.root+"/index.php":window.location.pathname)+"?option=com_ajax&format=json"}window.setInterval(function(){Joomla.request({url:n,onSuccess:function(){},onError:function(){}})},t)})}(window,document,Joomla);