Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger a javascript function when "Processing Math" in MathJax reaches 100%

I would like to call a javascript Print() function when the js library MathJax finishes to process the visited web page.

At the moment the Print() function is triggered using onload but it seems to stop the Processing Math task of MathJax (demo here); users need to dismiss the browser's Print pop-up to lets MathJax finishes its processing.

I would like to be able to call Print() just when Processing Math in MathJax reaches 100%.
Any ideas?

like image 914
systempuntoout Avatar asked Jan 08 '11 09:01

systempuntoout


1 Answers

Push the Print command onto the MathJax processing queue so that it will be called after MathJax finishes typesetting the page. E.g.,

MathJax.Hub.Queue(Print);

or

MathJax.Hub.Queue(function () {
  // do stuff here
  Print();
});

See the documentation at

http://www.mathjax.org/resources/docs/?queues.html#the-mathjax-processing-queue

for more details.

like image 80
Davide Cervone Avatar answered Oct 24 '22 18:10

Davide Cervone