Grepular

JSAPI Incompatible with XSLT

Written 14 years ago by Mike Cardwell

I’ve been developing a new website using XSLT. I try to use client side stylesheet translation when possible. I decided to use Googles language API in order to add some language translation to my site. You only seem to be able to use the Google language API by loading it via their general JSAPI tool. Eg, you would do this:

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
   google.load('language','1');
</script>

The trouble with this is, as soon as you call the google.load function, it blocks. When you do the XSL translation on the server side first, and just send plain HTML4, then it works fine and doesn’t block.

I have come up with a horrible hack to get around this problem whereby I create a hidden iframe, and within that iframe I load a pure html page which just does the jsapi stuff and then calls back to the parent window with the google object. However, I’m starting to think I should just give up on the idea of doing client side XSLT.

Want to leave a tip?BitcoinMoneroZcashPaypalYou can follow this Blog using RSS. To read more, visit my blog index.