Including External Javascript Code
Monkey Targets Forums/HTML5/Including External Javascript Code
| ||
If I have an external javascript lib, say, "http://webui.social.playphone.com/web_mnsapi/MNDirectHost.js.php," how do I get that included in my monkey project build? The line in the HTML file has to say something like,<script type="text/javascript" src="http://webui.social.playphone.com/web_mnsapi/MNDirectHost.js.php"></script> |
| ||
Not sure if this will work, but you could try this: Monkey File: [monkeycode]Strict Import "extern.js" Public Function Main:Int() Print "Start" Return 0 End[/monkeycode] extern.js: document.write("<script src='http://webui.social.playphone.com/web_mnsapi/MNDirectHost.js.php'><\/script>"); This does add the script to the file and then of course you will need to extern the functions. |
| ||
I think the <script src...> tag will need to be in MonkeyGame.html, so I guess the monkey builder needs to know to put it in there. Will what you've suggested do that? I guess I could always just put it in there manually too. |
| ||
It will get added to the main.js file: Generated Monkey code: document.write("<script src='http://webui.social.playphone.com/web_mnsapi/MNDirectHost.js.php'><\/script>"); function bbMain(){ push_err(); print("Start"); pop_err(); return 0; } function bbInit(){ } //${TRANSCODE_END} The document.write command will add it to the DOM and you will be able to access the external commands. |
| ||
Cool! I'll give it a shot. Thanks! |