Link to home
Start Free TrialLog in
Avatar of Jeff Heilman
Jeff HeilmanFlag for United States of America

asked on

Where to insert javascript in aspx code to maximize browser window when opened?

I have an aspx web form that I want to open with the browser maximized.  To do so I have found this code in a search here at EE.  The post says "Just insert it in your aspx code".  Can anyone tell me where exactly to insert it?

Here is the javascript to insert:
<script language="JavaScript1.2"> 
top.window.moveTo(0,0); 
if (document.all) 
   { top.window.resizeTo(screen.availWidth,screen.availHeight); } 
else if 
   (document.layers || document.getElementById) 
   { 
   if 
    (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth)
     { top.window.outerHeight = top.screen.availHeight; 
       top.window.outerWidth = top.screen.availWidth; } 
   } 
</script>

Open in new window

Here is my code for default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="LineStatus.LineStatus" %>

<!DOCTYPE html>
<link href="Stylesheet1.css" rel="stylesheet" type="text/css" />

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>"Production Line Status"</title>
    <meta http-equiv="refresh" content="30">
</head>
<body>
    <form id="form1" runat="server">
       
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Height="100%" Width="100%" Font-Size="X-Large" Font-Names="Calibri" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="2" ForeColor="Black" HorizontalAlign="Center" OnRowCreated="GridView1_RowCreated" CellSpacing="1" OnDataBound="OnDataBound" OnRowDataBound="GridView1_RowDataBound">
                <Columns>
                    
                    <asp:BoundField DataField="dept" ReadOnly="True" HeaderText="Production Line" ItemStyle-Width="120px" >
                    <ItemStyle Width="30%" HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>

                    <asp:BoundField DataField="shift" ReadOnly="True" HeaderText="Shift">
                    <FooterStyle HorizontalAlign="Center" />
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle Width="5%" HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>

                     <asp:BoundField DataField="produced" ReadOnly="True" HeaderText="Produced">
                    <ItemStyle Width="16.5%" HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>

                    <asp:BoundField DataField="target" ReadOnly="True" HeaderText="Target">
                    <ItemStyle Width="16.5%" HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>

                    <asp:BoundField DataField="diff" ReadOnly="True" HeaderText="+/-">
                    <HeaderStyle HorizontalAlign="Center" Width="5%" />
                    <ItemStyle Width="8%" HorizontalAlign="Center" />
                    </asp:BoundField>

                    <asp:BoundField DataField="associates" ReadOnly="True" HeaderText="Personnel">
                    <ItemStyle Width="8%" HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>

                    <asp:BoundField DataField="actualupwh" ReadOnly="True" HeaderText="Actual UPWH">
                    <FooterStyle HorizontalAlign="Center" />
                    <HeaderStyle HorizontalAlign="Center" Width="8%" />
                    <ItemStyle Width="8%" HorizontalAlign="Center" />
                    </asp:BoundField>

                    <asp:BoundField DataField="goalupwh" ReadOnly="True" HeaderText="Goal UPWH">
                    <HeaderStyle HorizontalAlign="Center" Width="8%" />
                    <ItemStyle Width="8%" HorizontalAlign="Center" />
                    </asp:BoundField>

                </Columns>
                <FooterStyle BackColor="#CCCCCC" />
                <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
                <RowStyle BackColor="White" />
                <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                <SortedAscendingHeaderStyle BackColor="#808080" />
                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                <SortedDescendingHeaderStyle BackColor="#383838" />
            </asp:GridView>
      </form>
</body>
</html>

Open in new window


Many thanks in advance.  I've been messing with this for quite some time with no luck.
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

You should be able to place the script block inside the head block just before the end tag.
Avatar of Jeff Heilman

ASKER

When I put it there though I get a "Validation (HTML5):  Attribute 'language' is not a valid attribute of element 'script'."  Not sure where to go from here.  Thanks for your help Shaun.
ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a million for the help!  I'm going to go patch the hole in my drywall from banging my head now.  Have a good day!