To avoid the XY problem, let me say that what I actually want is to embed Javascript code into <script>
tags in the HTML files produced via Org mode export, in such a way that (1) the Javascript code is included in the Org file (not a separate Javascript file), and (2) it is very easy to edit the Javascript in a Javascript specific major mode. The question title is only one way to achieve that.
Currently to embed Javascript in the resulting exported HTML I use:
#+BEGIN_EXPORT html
<script type="text/javascript">
// javascript code goes here
</script>
#+END_EXPORT
That works fine, of course, but I'd like to edit the Javascript code in a Javascript major mode. Using C-'
on an HTML block sensibly opens a buffer in HTML mode. So I've been using temp buffers I manually open and put in Javascript mode.
To embed code in an Org file that's conveniently editable in the correct major mode, you can use source blocks. Is there a way to get that Javascript code to export into a <script>
tag? Or some other convenient way to get what I want?
EDIT: Updated the #+BEGIN_HTML
to #+BEGIN_EXPORT html
for the shiny new Org 9.0, per @mutbuerger's suggestion.
#+BEGIN_EXPORT html
is shown in the resulting HTML file just like text ? Because I do :( What I get is<div class="export"> <p> <script type="text/javascript"> </script> </p> </div>
M-x org-version
.