[ASP.NET]在快顯視窗中使用超串連跳轉父視窗中的內容

來源:互聯網
上載者:User

 昨天遇到了一個問題,就是在用window.open開啟的視窗中增加一個超串連,當點這個串連時候要把父視窗的內容跳轉到另一個頁面,後面終於解決此問題,現在特來與大家分享下。

 

1.為了方便整個工程使用,我特意將這個方法寫成了一個js檔案。

// JScript 檔案
function pageClass(o) {
    for (x in o) this[x] =o[x];   
    this.open = function () {
       
        var pageBody = $$("pageBody");       
        var pageTitle = $$("pageTitle");       
        this.prevPage = pageBody.page;       
        //if (pageBody.page&&this.loc==pageBody.page.loc) {
        //    return;
        //}
        if (this.inherit) {
       
            this.loc = (pageBody&&pageBody.page?(pageBody.page.loc + "^"):"") + this.loc;
            delete this.inherit;
        }
        pageTitle.innerText = this.loc.replace(//^/gi,"->");
        window.open("about:bland","pageBody","",true);       
        window.open(this.url,"pageBody","",true);
        pageBody.page = this;
    }
}

 

2.在父視窗中添加一個用戶端function

如:

註:需要在父視窗中先載入剛才建立的js檔案,此處的參數id是傳入的某條資料的id,如果沒有可以不加

function openrRedirect(id) {
            new pageClass({url:"test.aspx?id=" + id,loc:"title"}).open();
        }

 

3.最後在了視窗中就可以添加<a>超串連了,只要直接調用父視窗的這個方法就可以了。

<a href="#"onclick="javascript:opener.openrRedirect.call(opener,id);/"></a>

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.