0

ページ読み込み時にファンシーボックスを開けてしまうシチュエーションですが、

以下の html と、私が使用している背後にあるコードを見つけてください。

protected void Page_Load(object sender, EventArgs e)
        {
            if (SessionController.CurrentMember != null)
            {
                if (Request.IsAuthenticated)
                {
                    int memberId = SessionController.CurrentMember.MemberID;
                    bool checkaccepted = CheckAcceptedTermsandConditions(memberId);

                    if (!checkaccepted)
                    {
                        string script = @"<script>$(document).ready(function() {

                 $(""#onlineCasinoTandC"").fancybox({
                 'transitionIn'  :   'elastic',
                 'transitionOut' :   'elastic',
                  'speedIn'     :   600, 
                    'speedOut'    :   200, 
                    'overlayShow'   :   false,
                     'overlayOpacity':   0.5,
                       'width'         :   800,
                        'showCloseButton':  true,
                         });
                    $(""#onlineCasinoTandC"").click();
                    });</script>";

                        ClientScript.RegisterStartupScript(this.GetType(), "fancybox", script);
                        onlineCasinoTandC.HRef = "/Common/EN/TermsandConditions.aspx";
                    }

                }
            }

        }

よろしくSrividhya

4

2 に答える 2

0

以下の解決策を見つけてください。

ページの読み込み時

string script = @"<script type=""text/javascript"">$(document).ready(function() {$(""#termsandConditions"").fancybox({'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':200,'overlayShow':false,'overlayOpacity': 0.5,'width':800,'href':""/Contents/Common/EN/TermandConditions.aspx""}).trigger('click');});</script>";
                    Type cstype = this.GetType();
                    ClientScriptManager cs = Page.ClientScript;

                    if (!cs.IsStartupScriptRegistered(cstype, script))
                    {
                        cs.RegisterStartupScript(cstype, "fancybox", script);
                    }

よろしくヴィディア

于 2012-04-19T10:30:46.343 に答える
0

この行の末尾にある余分なコンマを削除します

'showCloseButton':  true

そして、クリックイベントをトリガーしたい場合は、次のようにする必要があります

$('#foo').trigger('click');
于 2012-04-17T10:39:06.623 に答える