3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Leksiq
0

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 = '';
                        }

</script>

<!-- 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>

</div>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.