I need to use document.write() in XSL. Will it work ? Please help

If you should use inside an XSL file a script with document.write() and you cannot edit it(some counter for example), the next trick can help:

<script type="text/javascript">
// this is your script somewhere in HEAD
                        var document_write = '';
                        var obj = null;
                        document.write = function(str) {
                            document_write += str;
                        function begin(id) {
                            obj = document.getElementById(id);
                        function end() {
                            if(obj) {
                                obj.innerHTML = document_write;
                            document_write = '';


<!-- somewhere in BODY where you plan use another's script -->
<div id="some_id">
     <script type="text/javascript">begin('some_id');</script>
     <script type="text/javascript" src="http://www.other-domain.com/some_script_with_document_write.js"></script>
     <script type="text/javascript">end();</script>