Hallo,

I created a patch for the new exporter, so I can adding onload and onunload attributes to the body tag in HTML export.


I'm rather new to emacs lisp, please check if this is to be included in org-mode.

Best regards
Robert

--
Robert Klein - Max Planck-Institut für Polymerforschung
Ackermannweg 10
55128 Mainz
diff --git a/contrib/lisp/org-e-html.el b/contrib/lisp/org-e-html.el
index fcdf006..78582a5 100644
--- a/contrib/lisp/org-e-html.el
+++ b/contrib/lisp/org-e-html.el
@@ -132,7 +132,9 @@
    (:html-table-tag nil nil org-e-html-table-tag)
    (:xml-declaration nil nil org-e-html-xml-declaration)
    (:LaTeX-fragments nil "LaTeX" org-export-with-LaTeX-fragments)
-   (:mathjax "MATHJAX" nil "" space)))
+   (:mathjax "MATHJAX" nil "" space)
+   (:html-body-onload nil nil org-e-html-body-onload)
+   (:html-body-onunload nil nil org-e-html-body-onunload)))
 
 
 
@@ -996,6 +998,33 @@ CSS classes, then this prefix can be very useful."
   :type 'string)
 
 
+;;;; Template :: body-onload
+
+(defcustom org-e-html-body-onload nil
+  "Additional onload attribute for HTML body tags.
+The value of this variable is inserted in a onload attribute of
+the body tag in the HTML buffer.  Use this variable to include
+script code to be executed after loading the HTML page."
+  :group 'org-export-e-html
+  :type '(choice 
+          (const :tag "No preamble" nil)
+	  ((string  ) :tag "Custom string")))
+
+
+;;;; Template :: body-onunload
+
+(defcustom org-e-html-body-onunload nil
+  "Additional onunload attribute for HTML body tags.
+The value of this variable is inserted in a onunload attribute of
+the body tag in the HTML buffer.  Use this variable to include
+script code to be executed when leaving the HTML page."
+  :group 'org-export-e-html
+  :type '(choice 
+          (const :tag "No preamble" nil)
+	  ((string  ) :tag "Custom string")))
+
+
+
 
 ;;; Internal Functions
 
@@ -1422,7 +1451,16 @@ holding export options."
    (org-e-html--build-style info)
    (org-e-html--build-mathjax-config info)
    "</head>\n"
-   "<body>\n"
+   "<body"
+   (let ((body-onload (plist-get info :html-body-onload)))
+     (when body-onload
+       (if (stringp body-onload)
+	   (format " onload=\"%s\"" body-onload))))
+   (let ((body-onunload (plist-get info :html-body-onunload)))
+     (when body-onunload
+       (if (stringp body-onunload)
+	   (format " onunload=\"%s\"" body-onunload))))
+   ">\n"
    (let ((link-up (org-trim (plist-get info :link-up)))
 	 (link-home (org-trim (plist-get info :link-home))))
      (unless (and (string= link-up "") (string= link-up ""))

Reply via email to