SlideShare a Scribd company logo
Lecture 20
Referring to Unnamed
Frames Numerically
This is the last topic with using Frames in JavaScript. Like we did with Forms, same is
the case with Frames. If we don’t give any name to forms, then in JavaScript first form is
referred as forms [0], second form is referred as forms [1]. This is because; JavaScript
maintains an array of all the forms.
Similarly, if frames are unnamed, i.e. we don’t give any name to frames, then in
JavaScript first frame is referred as frames [0], second frame is referred as frames [1],
and so on.

Let us take an example.
Below is the code for frameset.html
<HTML>
        <frameset cols="50%,50%">
               <frame src="frame1.html">
               <frame src="frame2.html">
</frameset>
</HTML>

Below is the code for frame1.hmtl
<HTML>
<HEAD>
<TITLE> Frame 1</TITLE>
<script language="JavaScript">
        function fn1()
        {
                window.alert("This is function in frame 1");
        }
</script>
</HEAD>
<BODY>
        This is frame 1 <br>
        <a href="#" onClick="parent.frames[1].fn1()"> Call Function in Frame2</a>
</BODY>
</HTML>

Below is the code for frame2.html
<HTML>
<HEAD>
<TITLE> Frame 2</TITLE>
<script language="JavaScript">
        function fn1()
        {
window.alert("This is function in frame 2");
        }
</script>
</HEAD>
<BODY>
        This is frame 2 <br>
        <a href="#" onClick="parent.frames[0].fn1()"> Call Function in Frame1</a>
</BODY>
</HTML>


History Object
History Object Properties

   •   Length: Returns the number of items in the current history list

History Object Methods

   •   Back(): Moves back n items in the history list
   •   Forward(): Moves forward n items in the history list
   •   Go(): Moves to item n in the history list

There are currently no History object events. This means you cannot associate any event
with the History object.

History object contains the list of URL’s that your browser has visited. In other words,
History object is an array of all URL’s visited so far with the current open browser.

Since History object is an array, so it must have a length property, which will give you
the number of URL visited so far.

 Generally, if you want to go back to the previous page, you click the back button in the
menu bar of your browser. And, in case you want to go back to the next page, you click
the forward button
Notice: When you open a browser, back and forward button both are disabled.

If you want, you can provide that buttons on your web page, so that user can move back
and forward using your buttons rather than using browser buttons.




There are three ways to implement back and forward buttons
1. Back and Forward Using History
   2. Back and Forward Buttons (Simple)
   3. Back and Forward Buttons Without History

Back and Forward Using History
      Now, we will understand How to code back and forward button using history.

Below is the code
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script LANGUAGE="JavaScript">
        function back()
        {
               history.go(-1);
        }

        function forward()
        {
               history.go(+1);
        }
</script>
</HEAD>

<BODY>
<FORM>
<INPUT TYPE="button" VALUE="<< Back" onClick="back()">
<INPUT TYPE="button" VALUE="Forward >>" onClick="forward()">
</FORM>
</BODY>
</HTML>

Back and Forward Button (Simplest Way)

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script LANGUAGE="JavaScript">
        function back()
        {
               Location.href=”a.html”;
        }

       function forward()
       {
              Location.href=”b.html”
}
</script>
</HEAD>

<BODY>
<INPUT TYPE="button" VALUE="<< Back" onClick="back()">
<INPUT TYPE="button" VALUE="Forward >>" onClick="forward()">
</BODY>
</HTML>

Back and Forward buttons without using history object

<script language="JavaScript">

var MyLocation=window.location;

var MyPage=new Array;

{

       MyPage[0]="index.html";

       MyPage[1]="alerts.htm";

       MyPage[2]="alertsText.htm";

       MyPage[3]="alertsImages.htm";

       MyPage[4]="jumpfunction.htm";

       MyPage[5]="alertConfirm.htm";

       MyPage[6]="alertConfirm2Locs.htm";

       MyPage[7]="alertOnLoad.htm";

       MyPage[8]="alertHelloEx.htm";

       MyPage[9]="alertPrompts.htm";

       MyPage[10]="documentWrite.htm";

       MyPage[11]="documentWrite2.htm";
MyPage[12]="WindowNew.htm";

      MyPage[13]="WindowNew2.htm";

      MyPage[14]="WindowNewHyperlinks.htm";

      MyPage[15]="menu1.htm";

      MyPage[16]="menuSelectOnChange.htm";

      MyPage[17]="ArrayText.htm";

      MyPage[18]="jsFrames.htm";

      MyPage[19]="frameHyperlinks.htm";

      MyPage[20]="BackForward.htm"; }

function GoBack() {

if (ThisPageNumber <=0) {

alert("You are at the beginning of this series");

}

else{ ThisPageNumber=ThisPageNumber-1;

window.location=MyPage[ThisPageNumber];

}}

function GoForward(){

ThisPageNumber=ThisPageNumber+1;

if (ThisPageNumber >=MyPage.length) {

answer=confirm("You are at the end of the present series. "+

"Press ok to go to the beginning. Cancel to stay here");

if (answer!=0) {
ThisPageNumber=0; window.location=MyPage[ThisPageNumber]; }
ThisPageNumber=ThisPageNumber-1;

}

else {

window.location=MyPage[ThisPageNumber];

}

}

</script>

More Related Content

PDF
Database connectivity in PHP
Vineet Kumar Saini
 
RTF
dfhdf
guest635119
 
PPTX
Select * from internet
markandey
 
DOC
yazılı
guest1a815d9
 
PPTX
Java script events
AbhishekMondal42
 
PPTX
Advance JFACE
Rahul Shukla
 
DOCX
Add row in asp.net Gridview on button click using C# and vb.net
Vijay Saklani
 
PPTX
Operators
Kumar
 
Database connectivity in PHP
Vineet Kumar Saini
 
Select * from internet
markandey
 
yazılı
guest1a815d9
 
Java script events
AbhishekMondal42
 
Advance JFACE
Rahul Shukla
 
Add row in asp.net Gridview on button click using C# and vb.net
Vijay Saklani
 
Operators
Kumar
 

What's hot (20)

PPT
Javascript Experiment
wgamboa
 
PPTX
5. CodeIgniter copy1
Razvan Raducanu, PhD
 
PDF
Asp 3-html helpers in asp.net
Fajar Baskoro
 
PPTX
13. view data
Razvan Raducanu, PhD
 
PDF
Jqeury ajax plugins
Inbal Geffen
 
PPTX
Lesson 202 02 oct13-1800-ay
Codecademy Ren
 
KEY
UIWebView Tips
Katsumi Kishikawa
 
DOCX
Url&doc html
akila m
 
PPTX
Intro to DTCoreText: Moving Past UIWebView | iOS Development
SmartLogic
 
PPTX
5. hello popescu
Razvan Raducanu, PhD
 
ODP
XPages Extension Library - Create an app in 1 hour (almost)
Per Henrik Lausten
 
PPTX
jQuery basics for Beginners
Pooja Saxena
 
PPTX
Java script
Gourishankar R Pujar
 
PPT
symfony & jQuery (phpDay)
Massimiliano Arione
 
PDF
Laravel the right way
Matheus Marabesi
 
PDF
Broadleaf Presents Thymeleaf
Broadleaf Commerce
 
PPTX
HTML Forms
bismakhan12
 
PDF
Advanced Interfaces and Repositories in Laravel
Jonathan Behr
 
PDF
CGI::Prototype (NPW 2006)
brian d foy
 
Javascript Experiment
wgamboa
 
5. CodeIgniter copy1
Razvan Raducanu, PhD
 
Asp 3-html helpers in asp.net
Fajar Baskoro
 
13. view data
Razvan Raducanu, PhD
 
Jqeury ajax plugins
Inbal Geffen
 
Lesson 202 02 oct13-1800-ay
Codecademy Ren
 
UIWebView Tips
Katsumi Kishikawa
 
Url&doc html
akila m
 
Intro to DTCoreText: Moving Past UIWebView | iOS Development
SmartLogic
 
5. hello popescu
Razvan Raducanu, PhD
 
XPages Extension Library - Create an app in 1 hour (almost)
Per Henrik Lausten
 
jQuery basics for Beginners
Pooja Saxena
 
symfony & jQuery (phpDay)
Massimiliano Arione
 
Laravel the right way
Matheus Marabesi
 
Broadleaf Presents Thymeleaf
Broadleaf Commerce
 
HTML Forms
bismakhan12
 
Advanced Interfaces and Repositories in Laravel
Jonathan Behr
 
CGI::Prototype (NPW 2006)
brian d foy
 
Ad

Similar to Java script frame history (20)

RTF
Java script frame window
H K
 
PPSX
Introduction to Html5
www.netgains.org
 
PPTX
jQuery
PumoTechnovation
 
PPTX
Javascript 2
pavishkumarsingh
 
PDF
Devoxx 2014-webComponents
Cyril Balit
 
PDF
lect4
tutorialsruby
 
PDF
lect4
tutorialsruby
 
PPTX
Unit5_Web_Updvvgxsvjbffcvvgbjifszated.pptx
1si23bt001
 
PPTX
lec 14-15 Jquery_All About J-query_.pptx
MuhammadAbubakar114879
 
PPTX
Client Web
Markiyan Matsekh
 
PPTX
Unit3.pptx
AnamikaRai59
 
PPTX
Wt unit 5
team11vgnt
 
PDF
Introduction to jQuery
Seble Nigussie
 
ODP
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Nagios
 
PPTX
Unit – II (1).pptx
DrDhivyaaCRAssistant
 
KEY
Html5 For Jjugccc2009fall
Shumpei Shiraishi
 
PPTX
Django crush course
Mohammed El Rafie Tarabay
 
PDF
Jquery
Gulbir Chaudhary
 
PDF
HTML5 New and Improved
Timothy Fisher
 
Java script frame window
H K
 
Introduction to Html5
www.netgains.org
 
Javascript 2
pavishkumarsingh
 
Devoxx 2014-webComponents
Cyril Balit
 
Unit5_Web_Updvvgxsvjbffcvvgbjifszated.pptx
1si23bt001
 
lec 14-15 Jquery_All About J-query_.pptx
MuhammadAbubakar114879
 
Client Web
Markiyan Matsekh
 
Unit3.pptx
AnamikaRai59
 
Wt unit 5
team11vgnt
 
Introduction to jQuery
Seble Nigussie
 
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Nagios
 
Unit – II (1).pptx
DrDhivyaaCRAssistant
 
Html5 For Jjugccc2009fall
Shumpei Shiraishi
 
Django crush course
Mohammed El Rafie Tarabay
 
HTML5 New and Improved
Timothy Fisher
 
Ad

More from H K (20)

PDF
Assignment4
H K
 
DOCX
Assignment3
H K
 
PDF
Induction
H K
 
PDF
Solution3
H K
 
PDF
Solution2
H K
 
DOCX
Mid-
H K
 
PDF
Assignment4
H K
 
PDF
Assignment4
H K
 
PDF
Dm assignment3
H K
 
PPT
Proof
H K
 
PDF
Resolution
H K
 
DOCX
Assignment description
H K
 
PDF
Dm assignment2
H K
 
PDF
Set
H K
 
PDF
Dm assignment1
H K
 
PPTX
Logic
H K
 
DOCX
Introduction
H K
 
PDF
Assignment 2 sol
H K
 
PDF
Assignment sw solution
H K
 
PDF
Violinphoenix
H K
 
Assignment4
H K
 
Assignment3
H K
 
Induction
H K
 
Solution3
H K
 
Solution2
H K
 
Mid-
H K
 
Assignment4
H K
 
Assignment4
H K
 
Dm assignment3
H K
 
Proof
H K
 
Resolution
H K
 
Assignment description
H K
 
Dm assignment2
H K
 
Set
H K
 
Dm assignment1
H K
 
Logic
H K
 
Introduction
H K
 
Assignment 2 sol
H K
 
Assignment sw solution
H K
 
Violinphoenix
H K
 

Recently uploaded (20)

PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
CDH. pptx
AneetaSharma15
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
CDH. pptx
AneetaSharma15
 

Java script frame history

  • 1. Lecture 20 Referring to Unnamed Frames Numerically This is the last topic with using Frames in JavaScript. Like we did with Forms, same is the case with Frames. If we don’t give any name to forms, then in JavaScript first form is referred as forms [0], second form is referred as forms [1]. This is because; JavaScript maintains an array of all the forms. Similarly, if frames are unnamed, i.e. we don’t give any name to frames, then in JavaScript first frame is referred as frames [0], second frame is referred as frames [1], and so on. Let us take an example. Below is the code for frameset.html <HTML> <frameset cols="50%,50%"> <frame src="frame1.html"> <frame src="frame2.html"> </frameset> </HTML> Below is the code for frame1.hmtl <HTML> <HEAD> <TITLE> Frame 1</TITLE> <script language="JavaScript"> function fn1() { window.alert("This is function in frame 1"); } </script> </HEAD> <BODY> This is frame 1 <br> <a href="#" onClick="parent.frames[1].fn1()"> Call Function in Frame2</a> </BODY> </HTML> Below is the code for frame2.html <HTML> <HEAD> <TITLE> Frame 2</TITLE> <script language="JavaScript"> function fn1() {
  • 2. window.alert("This is function in frame 2"); } </script> </HEAD> <BODY> This is frame 2 <br> <a href="#" onClick="parent.frames[0].fn1()"> Call Function in Frame1</a> </BODY> </HTML> History Object History Object Properties • Length: Returns the number of items in the current history list History Object Methods • Back(): Moves back n items in the history list • Forward(): Moves forward n items in the history list • Go(): Moves to item n in the history list There are currently no History object events. This means you cannot associate any event with the History object. History object contains the list of URL’s that your browser has visited. In other words, History object is an array of all URL’s visited so far with the current open browser. Since History object is an array, so it must have a length property, which will give you the number of URL visited so far. Generally, if you want to go back to the previous page, you click the back button in the menu bar of your browser. And, in case you want to go back to the next page, you click the forward button Notice: When you open a browser, back and forward button both are disabled. If you want, you can provide that buttons on your web page, so that user can move back and forward using your buttons rather than using browser buttons. There are three ways to implement back and forward buttons
  • 3. 1. Back and Forward Using History 2. Back and Forward Buttons (Simple) 3. Back and Forward Buttons Without History Back and Forward Using History Now, we will understand How to code back and forward button using history. Below is the code <HTML> <HEAD> <TITLE> New Document </TITLE> <script LANGUAGE="JavaScript"> function back() { history.go(-1); } function forward() { history.go(+1); } </script> </HEAD> <BODY> <FORM> <INPUT TYPE="button" VALUE="<< Back" onClick="back()"> <INPUT TYPE="button" VALUE="Forward >>" onClick="forward()"> </FORM> </BODY> </HTML> Back and Forward Button (Simplest Way) <HTML> <HEAD> <TITLE> New Document </TITLE> <script LANGUAGE="JavaScript"> function back() { Location.href=”a.html”; } function forward() { Location.href=”b.html”
  • 4. } </script> </HEAD> <BODY> <INPUT TYPE="button" VALUE="<< Back" onClick="back()"> <INPUT TYPE="button" VALUE="Forward >>" onClick="forward()"> </BODY> </HTML> Back and Forward buttons without using history object <script language="JavaScript"> var MyLocation=window.location; var MyPage=new Array; { MyPage[0]="index.html"; MyPage[1]="alerts.htm"; MyPage[2]="alertsText.htm"; MyPage[3]="alertsImages.htm"; MyPage[4]="jumpfunction.htm"; MyPage[5]="alertConfirm.htm"; MyPage[6]="alertConfirm2Locs.htm"; MyPage[7]="alertOnLoad.htm"; MyPage[8]="alertHelloEx.htm"; MyPage[9]="alertPrompts.htm"; MyPage[10]="documentWrite.htm"; MyPage[11]="documentWrite2.htm";
  • 5. MyPage[12]="WindowNew.htm"; MyPage[13]="WindowNew2.htm"; MyPage[14]="WindowNewHyperlinks.htm"; MyPage[15]="menu1.htm"; MyPage[16]="menuSelectOnChange.htm"; MyPage[17]="ArrayText.htm"; MyPage[18]="jsFrames.htm"; MyPage[19]="frameHyperlinks.htm"; MyPage[20]="BackForward.htm"; } function GoBack() { if (ThisPageNumber <=0) { alert("You are at the beginning of this series"); } else{ ThisPageNumber=ThisPageNumber-1; window.location=MyPage[ThisPageNumber]; }} function GoForward(){ ThisPageNumber=ThisPageNumber+1; if (ThisPageNumber >=MyPage.length) { answer=confirm("You are at the end of the present series. "+ "Press ok to go to the beginning. Cancel to stay here"); if (answer!=0) {