国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

JavaScript實現彈出子窗口并傳值給父窗口

2024-05-06 16:12:24
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了JavaScript實現彈出子窗口并傳值給父窗口,方法很簡單,這里推薦給大家,需要的朋友可以參考下
 
 

新建父窗口頁面:

加入以下腳本

 

復制代碼代碼如下:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>First</title>
</head>
<script type="text/javascript">
function ShowDialog(Url) 

      var  iWidth=560; //模態窗口寬度
      var  iHeight=300;//模態窗口高度
      var  iTop=(window.screen.height-iHeight-100)/2;
      var  iLeft=(window.screen.width-iWidth)/2;
      var returnValue=window.showModalDialog(Url, "newwindow", "dialogHeight:"+iHeight+"px; dialogWidth:"+iWidth+"px; toolbar:no; menubar:no; scrollbars:no; resizable:no; location:no; status:no;left:200px;top:100px;");
      document.getElementById("TextBox1").innerText=returnValue;

</script>
<body>
    <form id="form1" runat="server">
         <input id="Button1" type="button" value="button" onclick="ShowDialog('./second.aspx')" />
         <div><asp:TextBox ID="TextBox1" runat="server" Width="67px"></asp:TextBox></div>
     </form>
</body>
</html>

 

創建second.html頁面:

 

復制代碼代碼如下:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>second</title>
    <!--<base target="_self" ></base>-->
</head>
<script language="javascript">
    function closeDiag()
    {
        window.opener=null;
        window.close();
    }  
    function OK()
    {
        var Value=document.getElementsByName("myRadio");
        for(var i=0;i<Value.length;i++)
        {
            if(Value[i].checked)
            {  
                window.returnValue = Value[i].value;
                window.close();
            }
            else
            {
                document.getElementById("Lab_Info").innerText="沒有選中項,請選擇!";
            }
        }      
    }  
</script>
<body>
    <form id="form1" runat="server">
    <div>
          <asp:DataGrid ID="dgSjygl" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        BackColor="White" Font-Size="9pt" PageSize="5" Width="100%" Height="127px" OnItemDataBound="dgSjygl_ItemDataBound">
                        <PagerStyle Mode="NumericPages" />
                        <AlternatingItemStyle BackColor="Gainsboro" />
                        <ItemStyle BackColor="#EEEEEE" ForeColor="Black" HorizontalAlign="Center" />
                        <Columns>
                            <asp:TemplateColumn>             
                                <HeaderTemplate>
                                    <label>選擇</label>
                                </HeaderTemplate>
                                <ItemTemplate>                                    
                                    <input type="radio" id="myRadio" name="myRadio"  value='<%# DataBinder.Eval(Container.DataItem, "id") %>'>
                                </ItemTemplate>
                                <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="60px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateColumn>
                            <asp:BoundColumn DataField="ID" HeaderText="編號">
                                <HeaderStyle Font-Bold="True"  Width="75px" HorizontalAlign="Center"/>
                            </asp:BoundColumn>
                            <asp:BoundColumn DataField="MC" HeaderText="名稱">
                                <HeaderStyle Font-Bold="True"  Width="90px" HorizontalAlign="Center"/>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundColumn>
                            <asp:BoundColumn DataField="BT" HeaderText="標題">
                                <HeaderStyle Font-Bold="True" HorizontalAlign="Center"/>
                            </asp:BoundColumn>
                        </Columns>
                        <HeaderStyle BackColor="#7481BA" ForeColor="Yellow" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Font-Size="Small" />
                    </asp:DataGrid>
    </div>
    <div>
          <input id="Btn_OK" type="button" onclick="OK()" value="確 定"/>
          <input id="Btn_Cancel" type="button" onclick="clickDiag()"  value="取 消" />
     </div>        
    </form>
</body>
</html>

 

以上就是本人實現這個簡單功能的全部內容了,感覺應該還有更便捷的方法,有知道的小伙伴還請留言說明下。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 古丈县| 开江县| 石河子市| 银川市| 台南县| 建水县| 三明市| 开平市| 陈巴尔虎旗| 永吉县| 西昌市| 陆良县| 天等县| 杨浦区| 界首市| 鞍山市| 柳林县| 柯坪县| 蒙阴县| 西和县| 沁阳市| 灵武市| 榆树市| 铜山县| 文安县| 谷城县| 寿光市| 信阳市| 玉山县| 平湖市| 华亭县| 舟曲县| 德昌县| 大余县| 林口县| 富民县| 马尔康县| 沙雅县| 兴仁县| 综艺| 洛川县|