Skip to content

Instantly share code, notes, and snippets.

@contensis
Created October 10, 2014 08:40
Show Gist options
  • Save contensis/8447eefd65620e6b1522 to your computer and use it in GitHub Desktop.
Save contensis/8447eefd65620e6b1522 to your computer and use it in GitHub Desktop.
Working with JavaScript Files
' If the same URL is registered twice it will only output one reference.
' The URL is used as a key to prevent duplicates.
' Add a JavaScript file before the opening body tag
CurrentContext.Page.Scripts.Add("app.js")
' Add a JavaScript file before the closing body tag
CurrentContext.Page.Scripts.Add("app.js", ScriptLocation.BodyEnd)
' Add a JavaScript file before the opening body tag
CurrentContext.Page.Scripts.Add("app.js", ScriptLocation.BodyStart)
' Add an inline JavaScript file before the closing body tag
CurrentContext.Page.Scripts.AddInline("alert('Hello World!');")
' Add an inline JavaScript file before the closing body tag
CurrentContext.Page.Scripts.AddInline("alert('Hello World!');", ScriptLocation.BodyEnd)
' Add an inline JavaScript file after the opening body tag
CurrentContext.Page.Scripts.AddInline("alert('Hello World!');", ScriptLocation.BodyStart)
' Remove a JavaScript file reference from the page
CurrentContext.Page.Scripts.Remove("app.js")
' Register jQuery for use on the page
CurrentContext.Page.Scripts.RegisterJQuery
' Register Contensis Web API for use on the page
CurrentContext.Page.Scripts.RegisterContensisApi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment