SoFunction
Updated on 2025-04-03

JS Getting Started Code Collection


61. Can I scale the size of a new window?

1: <script language=”JavaScript”>  
2: ('http:///' , 'myNewWindow', 'resizable=yes' );</script>   


62 Load a new document to the current window

1: <a href='#' onClick=' = '';' >Open New Document</a>   


63 Set the scrolling position of the page

1: <script language=”JavaScript”>  
2: if () { //If it is an IE browser, use the scrollTop property.
3:  = 200;  
4: } else { //If it is a NetScape browser, use the pageYOffset property
5:  = 200;  
6: }</script>   


64 Open a full screen window in IE

1: <a href='#' onClick=”('/','newWindow','fullScreen=yes');”>Open a full-screen window</a>   


65 Operations of new windows and parent windows

1: <script language=”JavaScript”>  
2://Define a new window
3: var newWindow = (“”,”newWindow”);  
4:();//Close the open new window in the parent window
5: </script>  
6: Close the parent window in a new window
7: ()   


66 Write content in a new window

1: <script language=”JavaScript”>  
2: var newWindow = (“”,”newWindow”);  
3: ();  
4: (“This is a new window”);  
5: ();  
6: </script>   


67 Loading the page to the frame page

1: <frameset cols=”50%,*”>  
2: <frame name=”frame1” src="/”"”>  
3: <frame name=”frame2” src="/”about:blank"”>  
4: </frameset>  
5: Load the page in frame2 in frame1
6: parent. = “”;   


68 Share scripts between frame pages
If there is a script in the html file in frame1

1: function doAlert() {   
2: (“Frame 1 is loaded”);  
3: }   

Then this method can be called in frame2.

1: <body onLoad=”parent.();”>  
2: This is frame 2.  
3: </body>   


69 Data Publicity
Data items can be defined on the framework page so that the data can be shared by pages in multiple frameworks

1: <script language=”JavaScript”>  
2: var persistentVariable = “This is a persistent value”;  
3: </script>  
4: <frameset cols=”50%,*”>  
5: <frame name=”frame1” src="/”"”>  
6: <frame name=”frame2” src="/”"”>  
7: </frameset>   


In this way, the variable persistentVariable can be used in both frame1 and frame2
70 Framework Codebase
Based on some of the above ideas, we can use a hidden framework page as the code base for the entire framework set.

1: <frameset cols=”0,50%,*”>  
2: <frame name=”codeFrame” src="/”"”>  
3: <frame name=”frame1” src="/”"”>  
4: <frame name=”frame2” src="/”"”>  
5: </frameset>