Skip to main content

Posts

Showing posts with the label JavaScript

Dynamically Adding JavaScript files in the Head of a .Net Master Page

Sometimes javaScript files need to be sourced in the head of an HTML document; however the >net framework does not appear to update tIf you add a link element into the head of the .Net master page, e.g to use a style sheet, then the .Net framework takes care of sorting out the relative URI resource, so that the correct path for the style sheet is always used. e.g. linking to a style sheet in the head of a master page <link href="StyleSheetFile.css" rel="stylesheet" type="text/css" /> would be automatically converted, if you went in to a sub directory, to <link href="../StyleSheetFile.css" rel="stylesheet" type="text/css" /> However a source used to load a JavaScript file does not behave in the same way and the path remains as defined in the master page. e.g. linking to a javascript file in the head of a master page, no matter how deep in to the directory structure you go, will stay as <script sr...