Can I write Javascript code in XSLT?

Basically I will be calling Javascript's document.location.href to check which site is currently opened (English or Arabic). So let's say if English site is opened, I want to perform some operation in XSLT and if Arabic then I want to perform some different operation.

1 Answer 1


As I understand it, XSL is server-side and JS is client-side so you are trying to mix two incompatible layers. What you can do is include a reference to a JS script within your XSL which will then run against the rendered output.

In the example you mention, you could potentially render both language versions using your XSL and then hide whichever you prefer using your JS?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.