2013-03-10 18 views
0

我目前正在使用Smarty引擎的頁面進行一些更改。我對輸出JavaScript感到困惑,因爲當我查看頁面源時,沒有任何輸出,但是當我使用Firebug時,我輸出的JavaScript代碼是可見的。這是Smarty模板的正常行爲嗎?JavaScript輸出Smarty在頁面源中不可見

<script type="text/javascript"> 
    if (isThanksPage == true) {ldelim} 
    var biJsHost = (("https:" == document.location.protocol) ? "https://" : "http://"); 
    document.write('some javascript source code'); 
    {rdelim} 

    if (isThanksPage === true) {ldelim} 
     Order.SetCustomer('{$customerInfo.accountDetails.loginMail}', '{$customerInfo.shippingDetails.sFName}', '{$customerInfo.shippingDetails.sLName}'); 
     Order.OrderNumber = '{$orderId}'; 
     Order.OrderTotal = '{$totalAll|string_format:"%.2f"}'; 
     Order.ShippingTotal = '{if $shippingInfo.value eq 0}Free{else}${$shippingInfo.value|string_format:"%.2f"}{/if}'; 
    {rdelim} 
</script> 
     {assign var=totalWithoutTax value=`$total+$shippingInfo.value`} 
     {if $tax} 
     {assign var=taxValue value=`$tax*$totalWithoutTax/100`} 
     {else} 
     {assign var=taxValue value=0} 
     {/if} 
    {assign var=totalAll value=`$totalWithoutTax+$taxValue+$promoProduct.catalog_price`} 
<script type="text/javascript"> 
    if (isThanksPage == true) {ldelim} 
     Order.ItemTotal = '${$totalAll|string_format:"%.2f"}';  
    {rdelim} 
</script> 
     {foreach from=$cartProducts key=key item=product} 
     {if $product.freeItemNum} 
      <script type="text/javascript"> 
       if (isThanksPage == true) {ldelim} 
       Order.AddLineItem('{$product.productInfo[1]}', {$product.freeItemNum}, '0.00'); 
       {rdelim} 
      </script> 
     {/if} 

     {if $product.quantity > $product.freeItemNum} 
      {assign var=quantity value=`$product.quantity-$product.freeItemNum`} 
      {if $product.getYInfo.discountNumber >= $quantity} 
       {assign var=priceValue value=`$quantity*$product.getYInfo.discountPrice`} 
       {assign var=unitPriceValue value=`$product.getYInfo.discountPrice`} 
      {elseif $product.getYInfo.discountNumber neq 0} 
       {assign var=quantity1 value=`$quantity-$product.getYInfo.discountNumber`} 
       {assign var=quantity2 value=`$product.getYInfo.discountNumber`} 
       {assign var=priceValue value=`$quantity1*$product.sellPrice+$quantity2*$product.getYInfo.discountPrice`} 
       {assign var=unitPriceValue value=`$product.sellPrice`} 
      {else} 
       {assign var=priceValue value=`$quantity*$product.sellPrice`} 
       {assign var=unitPriceValue value=`$product.sellPrice`} 
      {/if} 
      <script type="text/javascript"> 
      if (isThanksPage == true) {ldelim} 
      Order.AddLineItem('{$product.productInfo[1]}', {$quantity}, '${$priceValue|string_format:"%.2f"}'); 
      {rdelim} 
      </script> 
     {/if} 
     {/foreach} 
     <script type="text/javascript"> 
     if (isThanksPage == true) {ldelim} 
     Order.Go(); 
     {rdelim} 
</script> 
+0

當你說「不輸出任何東西」時,你的意思是在頁面源代碼中沒有可見的Javascript,或者JavaScript向頁面添加內容,並且該內容在頁面源代碼中不可見? – IMSoP 2013-03-12 19:16:16

+0

我認爲這是我的錯誤。我使用某人的代碼,所以我不知道它是如何工作的。經過幾個小時的閱讀和嘗試,我發現,該螢火蟲返回當前的HTML代碼和CTRL + U返回鋤頭頁面 - 這是從重定向的頁面,如果沒有參數傳遞。 – 2013-03-13 09:12:35

回答

0

你能舉例說明一下代碼嗎?不,這不是正常行爲