[Xerte-dev] Re: Reading url parameters in Xerte via javascript - strange behaviour in IE8

Kemp Johnathan johnathan.kemp at ntlworld.com
Thu Apr 19 12:20:30 BST 2012


This is driving me crazy,

I have a working version using Xerte desktop and this error in toolkits.

I noticed that there were discrepancies between the dates of the files for
the xerte desktop swfs and the toolkits swfs so I swapped in the swfs one
by one from the desktop. Still no change.

So I set to create a common code block that I could use in both the desktop
and toolkits pages.rlo and Nottingham.rlt file, effectively using all the
same code except for the looking up of the returned url parameter as
tookits and xerte use different arrays. ( extXML.firstChild.childNodes v
rootIcon.pages).
Crucially they would be both using exactly the same code to capture the url
parameter and to display it in an alert box afterwards.

I got this working in the desktop project but when I copied the code block
over to Nottingham.rlt it killed my Xampp toolkits sites ability to preview
or run projects I just get loading xml. This even occurs when I replace the
Nottingham.rlt with the original which I had backed up.

I suspect there may be issues with the different versions of the various
swfs but cannot confirm this since my Toolkits site is now stuffed.

I don't have time to look at this further now, but may get some time over
the weekend.

Do you know if there is a version of Xampp that has all the latest support
files that will be part of the next release?

If there isn't is it simply a case of replacing all the files in the xampp
htdocs toolkits folder with the folders in the root of the XOT svn?

Will this cause issues with the databases?

Are the various support files e.g. the various swfs in the XOT svn updated
in line with any changes in the desktop version?

Kind regards

Johnathan

On 19 April 2012 11:09, Julian Tenney <Julian.Tenney at nottingham.ac.uk>wrote:

> I’m not sure, but this doesn’t make sense:
>
>
>
> try { __flash__toXML(alert("destinationPage = null")) ; } catch (e) {
> "<undefined/>"; }
>
>
>
> because earlier in the code you pass a string to toXML(), here you /
> something is passing the alert function.
>
>
>
>
>
> *From:* xerte-dev-bounces at lists.nottingham.ac.uk [mailto:
> xerte-dev-bounces at lists.nottingham.ac.uk] *On Behalf Of *Kemp Johnathan
> *Sent:* 18 April 2012 22:24
> *To:* Xerte Developers Discussion List
> *Subject:* [Xerte-dev] Reading url parameters in Xerte via javascript -
> strange behaviour in IE8
>
>
>
> Recently I have been working on opening up Xerte projects via a url which
> includes a parameter to specify which page to open the project at.
>
>
>
> I have a javascript function which returns a url parameter, you pass the
> name of the parameter in the function call and it returns the value for the
> parameter if that parameter name has been included in the url.
>
>
>
> When included in a html page it works reliably in IE8, Opera and Firefox.
>
>
>
> However when I add the function to the end of rloObject.js and open the
> Xerte project with a url like the following (running a Xampp install of XOT)
>
>
>
> http://localhost/toolkits/play.php?template_id=20&pageID=bullet
>
>
>
> and including in a script in the Xerte project the lines
>
>
>
> destinationPage = callJS("myFunction","pageID");
>
> callJS("alert"," destinationPage = " + destinationPage );
>
>
>
> In Opera or Firefox I get an alert box that displays "destinationPage =
> bullet"
>
> but in IE8 I get an alert box that displays " destinationPage = null"
>
>
>
> If I use the Developer Tools in IE 8 and put a break point in my function
> I can watch the parameter be correctly gathered by the javascript function
> and returned.
>
>
>
> The debugger then shows the next stage in the process as being back in the
> flash environment with the current line shown in yellow below
>
>
>
> function __flash__escapeXML(s) {
> return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g,
> ">").replace(/"/g, """).replace(/'/g, "'");
> }
> function __flash__toXML(value) {
> var type = typeof(value);
> if (type == "string") {
> return "<string>" + __flash__escapeXML(value) + "</string>";
> } else if (type == "undefined") {
> return "<undefined/>";
> } else if (type == "number") {
> return "<number>" + value + "</number>";
> } else if (value == null) {
> return "<null/>";
> } else if (type == "boolean") {
> return value ? "<true/>" : "<false/>";
> } else if (value instanceof Date) {
> return "<date>" + value.getTime() + "</date>";
> } else if (value instanceof Array) {
> return __flash__arrayToXML(value);
> } else if (type == "object") {
> return __flash__objectToXML(value);
> } else {
> return "<null/>"; //???
> }
> }
>
>
>
> If I set a watch on "value" it correctly displays in the watch with the
> value of the url parameter
>
> i.e. if my url has &pageID=bullet, and I called my function with
>
> destinationPage = callJS("myFunction"."pageID");
>
> then the watch shows "value" to be "bullet"
>
>
>
> Since the type is a string the function  __flash__escapeXML(s) gets
> called.
>
>
>
> If I set a watch on s in this function then this also displays with the
> value of "bullet"
>
>
>
> However when you step beyond the line
>
>
>
> return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g,
> ">").replace(/"/g, """).replace(/'/g, "'");
>
>
>
> the debugger changes to display
>
>
>
> try { __flash__toXML(alert("destinationPage = null")) ; } catch (e) {
> "<undefined/>"; }
>
>
>
> I don't know if the functions revealed by the debugger are part of Xerte
> or part of the browser's flash player, but the problem appears to lie here
> in that somehow even though the javascript has been able to return the url
> parameter to the flash environment, the flash environment is then returning
> a value of "null".
>
>
>
> If I can overcome this problem then it should be possible to call a XOT
> project via a url and open the project at a specific page in IE8, just as I
> now can if the project is opened in Firefox or Opera.
>
>
>
> Can anyone with more knowledge of the Flash side of things cast any light
> on what is going wrong or how to fix this?
>
>
>
> Kind regards
>
>
>
> Johnathan
>
>
>
>  This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it. Please do not
> use, copy or disclose the information contained in this message or in any
> attachment. Any views or opinions expressed by the author of this email do
> not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an
> attachment may still contain software viruses which could damage your
> computer system: you are advised to perform your own checks. Email
> communications with the University of Nottingham may be monitored as
> permitted by UK legislation.
>
> _______________________________________________
> Xerte-dev mailing list
> Xerte-dev at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it.   Please do
> not use, copy or disclose the information contained in this message or in
> any attachment.  Any views or opinions expressed by the author of this
> email do not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte-dev/attachments/20120419/3ccba6fe/attachment.html>


More information about the Xerte-dev mailing list