Including .JS on one page

MiServer is Dyalog's APL-based web development framework

Including .JS on one page

Postby MBaas on Tue Dec 02, 2014 5:34 am

I'd like to include a specific <script>-reference in the <head> of a certain MiPage. Is there way to do that from within the page or would I have to fiddle with the wrapper? (I've seen that I can Add meta from the page and it will appear in the head, but script unfortunately was injected in the body...
User avatar
MBaas
 
Posts: 156
Joined: Thu Oct 16, 2008 1:17 am
Location: Gründau / Germany

Re: Including .JS on one page

Postby Brian|Dyalog on Thu Dec 04, 2014 8:35 pm

Hi Michael!

I've posted an update to GitHub https://github.com/Dyalog/MiServer which fixes this. I had implemented some intelligence to properly locate elements that belong in <head> or <body>, but apparent it wasn't working completely correctly. That's been fixed with the 4 December 2014 update.

There are a couple of ways in include scripts:
  • use _html.script - this is the base HTML5 <script> element.
          (Add _html.script).Attr[⊂'src']←⊂'yourJSFile.js'
  • use _HTML.Script - this is the "augmented" version
          (Add _HTML.Script).File←'yourJSFile.js'
If you're using inline code as opposed to storing your JavaScript in a separate file, you can provide the code as an argument using either control:
      Add _html.script 'alert("hello")'
Add _HTML.Script 'alert("hello")'

I hope this helps!
/Brian
User avatar
Brian|Dyalog
 
Posts: 116
Joined: Thu Nov 26, 2009 4:02 pm
Location: West Henrietta, NY

Re: Including .JS on one page

Postby MBaas on Fri Dec 05, 2014 9:27 am

Thanks Brian, that's a nice solution and certainly helps :)
User avatar
MBaas
 
Posts: 156
Joined: Thu Oct 16, 2008 1:17 am
Location: Gründau / Germany


Return to MiServer

Who is online

Users browsing this forum: No registered users and 1 guest