The final piece in making this and the other local JavaScript work through the routing table is to wire it into the services.getPage
function. This will be easy.
Before that, we first need to write a new callBack
function to do something with the JavaScript that is in the content directories. And when it loads it, it loads into the header's SCRIPT
element, where it runs. Create a new function as a method of the services.routing
object called writeScript
. It will receive the variables XHTTP
, id
, and hash
.
services.routing.writeScript = function(xhttp,id,hash){ //Do Something };
Inside it, first create a new variable called newScript
equal to the document's createElement
method, creating a SCRIPT
element.
var newScript = document.createElement('script');
The newScript
variable has a property
, text
; set it equal to the string var id="
plus the hash
variable plus ";
. See the following example:
newScript.text = 'var id= "'+hash+'...