Forum

Standalone html and Javascript

20 July 2017 12:59
Hello,

currently I am using the development server on localhost:6687 to develop my application. I changed the my_project.js to meet my demands. But of course I don't want to have the development server running in background. So I want to export my model as json or standalone html, but I also need my script behaviour. How can I achieve this?
It is not possible to simply open the my_project.html in the project folder.

Thanks in advance,
glueckskeks
20 July 2017 14:07
Hi glueckskeks,
The reason Blend4Web (and many other web developers) use a local development is that browser security setting do not allow HTML files to pull script files from your local machine. This would be a security vulnerability. For testing, web developers use a local server to serve up their files. This gets around the browser security issue. The standalone HTML export has no external file dependancies, so it can run from anywhere. Once you start working with external JavaScript and JSON files, you need to run them from either your local development server or an online web server.
You can use logic nodes in your standalone HTML export. What functions are you trying to achieve with your Javascript? Maybe there is a way to do it with logic nodes.
20 July 2017 16:35
Reply to post of user Will Welker
What functions are you trying to achieve with your Javascript? Maybe there is a way to do it with logic nodes.

I want to set the anchor text dynamically and also I want to trigger an animation every time an external event occurs. The anchor text is received from a server and the animation trigger is also depending on the values received.
20 July 2017 16:48
You can do some network sending and receiving with logic nodes. LINK
For the dynamic anchor text, you will need to use the JavaScript API and run your project from a server.
 
Please register or log in to leave a reply.