Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (33 sloc) 1.49 KB

"Importing External JavaScript": Harlowe (v2.0)

Summary

"Importing External JavaScript" demostrates how to import an externally stored JavaScript library, jQuery UI.

This example uses the built-in jQuery $.getScript() function to load the library and demonstrates a short example of how to use it.

Note: The successful loading of an external JavaScript file or library commonly producess no visual output. The code within the example passage is not required for the succesful loading of an external file or library.

Live Example

<iframe src="harlowe_importexternaljs_example.html" height=400 width=90%></iframe>

Download: Live Example

Twee Code

:: StoryTitle
Harlowe: Importing External JavaScript


:: UserScript [script]
/* import jQuery UI library. */
$(function () {
	$.getScript("https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js",
		function (data, textStatus, jqxhr) {
			console.log('jquery ui file loaded');
		}
	);
});


:: Start
<p>Click on the grey box below to see it bounce.</p>
<div id="box" style="width: 100px; height: 100px; background: #ccc;"></div>
 
<script>
$("#box").click(function () {
  $("#box").toggle("bounce", {times: 3}, "slow");
});
</script>


Download: Twee Code