Fixing a host/domain issue in the AJAX Calendar Blogsphere Sideblock
by florian vogler :: Blogsphere Template
Just discovered a problem with the Calendar sideblock (see Calendar on the right hand side of this blogs homepage) yesterday and fixed it as follows:
This blog is available from both
http://www.panagenda.com/pub/panablog.nsf" and "http://blog.panagenda.com(/pub/panablog.nsf)"
- the Calendar sideblock fetches its data through an XMLHttpRequest, which (for security reasons I would understand if it actually were different hosts) does not allow to fetch data across different domains. As I specified "http://blog.panagenda.com/pub/panablog.nsf" as the homepage URL in the blog(sphere) configuration, anyone opening the blog through http://www.panagenda.com would get an error (silent or a messagebox even) "Permission denied".
To fix this, I opened the page "Javascript - AJAX Calendar|script/calendar.js". The problem is in the two computed text objects, that read the source URL for the calendar content from the blogsphere configuration - this needs to be adjusted to read the content from the host you actually open the blog from:
Change the two lines with the computed value objects as follows:
Then, you must also adjust the two Computed Text Formulas: both contain an @DbLookup, which simply needs to be changed to @WebDbName (replace the entrie existing formula).
Now the Calendar sideblock reads its contents from the respective host it is opened from.
This blog is available from both
http://www.panagenda.com/pub/panablog.nsf" and "http://blog.panagenda.com(/pub/panablog.nsf)"
- the Calendar sideblock fetches its data through an XMLHttpRequest, which (for security reasons I would understand if it actually were different hosts) does not allow to fetch data across different domains. As I specified "http://blog.panagenda.com/pub/panablog.nsf" as the homepage URL in the blog(sphere) configuration, anyone opening the blog through http://www.panagenda.com would get an error (silent or a messagebox even) "Permission denied".
To fix this, I opened the page "Javascript - AJAX Calendar|script/calendar.js". The problem is in the two computed text objects, that read the source URL for the calendar content from the blogsphere configuration - this needs to be adjusted to read the content from the host you actually open the blog from:
Change the two lines with the computed value objects as follows:
var dbCalendarPath='http://'+document.location.hostname+'/<Computed Value>';and
var a='http://'+document.location.hostname+'/<Computed Value>/agnt_AJAX_Calendar?OpenAgent(Note: the second line continues with &rdm='+Math.random() ... etc.)
Then, you must also adjust the two Computed Text Formulas: both contain an @DbLookup, which simply needs to be changed to @WebDbName (replace the entrie existing formula).
Now the Calendar sideblock reads its contents from the respective host it is opened from.
Comments
'http://'+document.location.hostname
I have used
window.location.protocol + '//' + window.location.host
to preserve the protocol and the port (if any).
Jens Polster, 2008-04-12 12:25
Florian Vogler, 2008-04-13 10:00
Florian Vogler, 2008-04-12 12:36