2013-01-02 69 views
1

我使用的fancybox提交併submiting我的表格後,我想redirtect我父頁面的一些指定的網址我使用的fancybox如下重定向父頁面裏面的fancybox

$(document).ready(function() { 
      $('[id*=addnewRequest]').fancybox({ 
       'width': 760, 
       'height': 540, 
       'padding': 0, 
       'margin': 0, 
       'hideOnOverlayClick': false, 
       'scrolling': 'auto', 
       'autoScale': false, 
       'transitionIn': 'none', 
       'transitionOut': 'none', 
       'type': 'iframe', 
       'centerOnScroll': true, 
       'onClosed': function() { 

        if ($.redirTo != null && $.redirTo.length > 0){ 

         window.location.replace($.redirTo); 
        } 

        else { 
         parent.location.reload(true); 
        } 
       } 
      }); 
     }); 

和submiting後指定的URL我形成我使用下面的寄存器腳本,「redirectTo」是URL,我想我的父頁面會重定向

ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "add", "parent.jQuery.redirTo='" + redirectTo + "'; parent.jQuery.fancybox.close();", true); 

現在我的父頁面將如何重定向到perticular url.Any想法?

感謝,

回答

2

submiting表單之後就可以直接調用window.top.location.href新網址爲:

window.top.location.href = "http://www.urltogo.com/pagetomove.aspx"; 

,並避免對家長髮送參數,並從那裏進行重定向。

下面是一個例子(我加5秒的延遲有時間看看吧)

http://jsfiddle.net/u6whQ/3/http://jsfiddle.net/u6whQ/4/

你行可能會像:

ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "add", "window.top.location.href ='" + redirectTo + "'; parent.jQuery.fancybox.close();", true); 
+1

非常感謝。它的作品... –

+1

@GurbaxSinghBhangal不客氣,歡迎新年快樂。 – Aristos

+0

也祝你新年快樂。 –