Hi Livecode community,
This is my first post. So please forgive me if my question should belong to another thread.
I am new to Livecode, coming from JavaScript, AS3 etc. I did some experiments with the browser widget. I successfully managed the 2-directional communication (LC to JS and JS to LC). What i try to achieve: building a LC-Standalone Application capable of "cleaning up" SVG-files located in local html files. This works fine already.
The next step would be to set animation params and play the SVG-animation within the browser widget. This doesnt work well.
Here is my problem:
The final animation is done in JavaScript (own script, no jQuery).
To keep the HTML/JavaScript clean, the JavaScript files are kept separated (external files)
When tested purely in a "normal" Browser, animations work as aspected. So: the JavaScript is fine.
But: when loaded into the browser widget, animations wont play.
Testing:
This also happens, when using JS frameworks. In this case: Snap.js
More testing:
Instead of using an external JavaScript file, i copied that into the main html file. Bingo: now this works also in the browser widget !?
So my question is:
- Does the "liveCode"-Object (LCs extension to the browser) interferes with external .js files ?
- Is this a known issue?
- work arounds?
- btw. i am using the community edition
Thanks in advance, Folko
Browser Widget and external JavaScript files
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Browser Widget and external JavaScript files
Hi Folko,
welcome to the forum!
Hm, sounds like a path problem. Are you also using external HTML files?
If yes, put the JS files into the same folder as the html.
Unfortunately I do not know what the browser widget thinks is the current "defaultfolder".
On what platform are you experiencing this in a standalone?
Does it work in the IDE?
Best
Klaus
welcome to the forum!
Hm, sounds like a path problem. Are you also using external HTML files?
If yes, put the JS files into the same folder as the html.
Unfortunately I do not know what the browser widget thinks is the current "defaultfolder".
On what platform are you experiencing this in a standalone?
Does it work in the IDE?
Best
Klaus
Re: Browser Widget and external JavaScript files
Hi Klaus,
thank you for answering.
I did some further investigations: external js files do not cause the problem per se. It´s the browsers window object!
Explanation: i am used to attach variables or objects to the top level window object. This works in all browsers. But it seems the LC browser does not like this.
So i have to reorganize my javascript.
Thanks again, Folko
thank you for answering.
I did some further investigations: external js files do not cause the problem per se. It´s the browsers window object!
Explanation: i am used to attach variables or objects to the top level window object. This works in all browsers. But it seems the LC browser does not like this.
So i have to reorganize my javascript.
Thanks again, Folko
Re: Browser Widget and external JavaScript files
Ok. There is a much more simpler explanation:
When using the browser widget just to load/show html, it works as expected. Also, external javascript files work.
What i did: load the html into a variable, manipulate things, put the result into the widget. This works partly. In this case, the html content is located in memory. Therefore, links to external javascript files might not work. I think, there is no way to "force" loading the externals, is it?
Workarounds:
- First save the result back to file. Then reload it.
- Or: copy the external js into the html variable temporarily.
Folko
When using the browser widget just to load/show html, it works as expected. Also, external javascript files work.
What i did: load the html into a variable, manipulate things, put the result into the widget. This works partly. In this case, the html content is located in memory. Therefore, links to external javascript files might not work. I think, there is no way to "force" loading the externals, is it?
Workarounds:
- First save the result back to file. Then reload it.
- Or: copy the external js into the html variable temporarily.
Folko