簡體   English   中英

使用JavaScript在新窗口中呈現文本框內容

[英]Text box content rendering in a new window using javascript

我有一個asp.net文本框(在轉發器中的textarea對每個記錄都是單個texarea,這是只讀的),當我單擊它時,我需要一個按鈕(在新窗口中打開)以顯示文本區域的內容使用javascript的新窗口。 類似於專家交流。

抱歉,我第一次讀錯了問題。

這是一個JavaScript解決方案:

function DisplayTextFromRepeater() 
{
    var text = '';
    var repeater = document.getElementById('MyRepeater');
    var inputs = repeater.getElementsById('input');
    var txtId = 'MyTextBox' //ID of textbox in repeater template

    for(var i = 0; i < inputs.length; i++) 
    {
        if(inputs[i].type == 'text') 
        {
            if(inputs[i].id.indexOf(txtId) != -1) 
            {
                text = text + inputs[i].value;
            }
        }
    }

    OpenNewWindow(text);
}

function OpenNewWindow(message)
{ 
    var OpenWindow = window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars=yes,menubar=no");
    OpenWindow.document.write("<html>");
    OpenWindow.document.write("<title>Title Goes Here</title>");
    OpenWindow.document.write("<body>");
    OpenWindow.document.write(message);
    OpenWindow.document.write("</body>");
    OpenWindow.document.write("</html>");
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM