I've no idea why Firefox should crash, but I think you've got the wrong end of the stick about the relationship between XSLT and Javascript.
Your XSLT is creating an HTML page, which happens to contain some Javascript. When it's finished creating the HTML page, the page can be loaded and that might cause the Javascript to execute. There's no possibility of the Javascript creating variables that the XSLT can access, because the Javascript doesn't start executing until the XSLT has finished.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference