试图在if-else中执行JavaScript

时间:2013-06-05 21:05:45

标签: javascript

private void GoogleAnalyticsJavascript()
{
//...
}

private void WriteMetaTags()
        {

                try
                {
                    MetaTagHelper metaControl = new MetaTagHelper();
                    metaControl.AddMetaTag("WT.pn_sku", GetSemicolonSeparatedValues(this.CurrentOrder, "ProductCode"), this.Page);
                    metaControl.AddMetaTag("WT.tx_u", GetSemicolonSeparatedValues(this.CurrentOrder, "Quantity"), this.Page);
                    metaControl.AddMetaTag("WT.tx_s", GetSemicolonSeparatedValues(this.CurrentOrder, "Total"), this.Page);
                    metaControl.AddMetaTag("WT.tx_e", "p", this.Page);
                    metaControl.AddMetaTag("WT.si_n", "Purchase", this.Page);
                    metaControl.AddMetaTag("WT.si_x", "7", this.Page);
                    metaControl.AddMetaTag("WT.ti", "Receipt", this.Page);
                    metaControl.AddMetaTag("WT.si_cs", "1", this.Page);
                    metaControl.AddMetaTag("WT.tx_cartid", this.CurrentOrder.Id, this.Page);
                    metaControl.AddMetaTag("WT.tx_i", this.CurrentOrder.OrderNumber, this.Page);
                    metaControl.AddMetaTag("WT.tx_id", this.CurrentOrder.DateModified.Value.ToString("d"), this.Page);
                    metaControl.AddMetaTag("WT.tx_it", this.CurrentOrder.DateModified.Value.ToString("H:mm:ss"), this.Page);

                    GoogleAnalyticsJavascript();

                }


                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                }
            }

上面的代码有效,但是当我转到“crazy.aspx”页面时,我想要GoogleAnalyticsJavaScript()只能触发。我正在使用它,但它不起作用。

string currentUrl = Request.Url.AbsoluteUri;
if (currentUrl.ToLower().Contains("crazy.aspx"))
{
    GoogleAnalyticsJavascript();
}

有什么建议吗?

0 个答案:

没有答案