![](/img/trans.png)
[英]Way to create a xsl variable using javascript variable from another file?
[英]Is it possible to create a xsl variable from javascript?
<xsl:variable name="delivery">
<script language="javascript" type="text/javascript"> document.getElementById('id').value;</script>
</xsl:variable>
是否可以像上面的示例一樣從javascript創建xsl變量?
不,XSLT轉換首先發生,然后在第二個單獨的步驟中,瀏覽器可能會呈現包含一些腳本代碼的轉換結果並執行該腳本。 所以用你的樣品
<xsl:variable name="delivery">
<script language="javascript" type="text/javascript"> document.getElementById('id').value;</script>
</xsl:variable>
在XSLT轉換期間, delivery
變量的值是一個結果樹片段,其中包含一個script
元素節點,該script
元素節點包含一個文本節點(碰巧是客戶端Javascript代碼),但是在XSLT轉換期間沒有腳本執行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.