-->
Page 1 of 3

Request: Javascript example

PostPosted: Tue Nov 03, 2015 9:15 am
by matherp
If anyone can post some simple example code which loads/runs a javascript file it would be very much appreciated

Re: Request: Javascript example

PostPosted: Tue Nov 03, 2015 7:39 pm
by Mmiscool
Hello.

The javascript command will add a
Code: Select all<script src="myscripts.js"></script>


into the html buffer.

If you have upload a ".js" file in the file manager you can include it in to your page by using the java script command.

Will work on putting a demo together with some practical application.

Re: Request: Javascript example

PostPosted: Thu Nov 05, 2015 1:20 pm
by matherp
Mike

I've written a trivial javascript file and shown that it runs by using "document.write" inside the script.

The big question of course is whether there is any mechanism of getting data from the Basic program into the javascript and whether any Basic variable can be manipulated by the javascript so that its changed value is available to Basic?

Thanks

Peter

Re: Request: Javascript example

PostPosted: Thu Nov 05, 2015 5:27 pm
by Mmiscool
The msg url and the msgbranch command could be used for this.

I have n example here.
http://www.esp8266basic.com/msg-url-usage.html


Used in conjunction with the following java script you can do some cool things.

Code: Select allfunction httpGet(theUrl)
{
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
    xmlHttp.send( null );
    return xmlHttp.responseText;
}


The above javascript code could be used to push and pull data from the esp with the above example.