Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Apr 20, 2000

Dynamically Loading Different Files Into Frames

Using the frame's location object, you can load a number of different files into a frame at runtime. As you do when building any project using frames, first build a file that defines your frame. For our example, we defined a frame called myframe. The code below would then go in a separate file.

Placed in the BODY of the code is a list of files from which the user can choose. When a user clicks on the file name he wants to load, the name of the file is passed as a parameter to the function. The function appends the ".htm" extension to the name, and assigns the complete name to the location object of the frame myframe, which loads the appropriate file into that frame.
 
<HTML>
<HEAD>
<TITLE> History topics </TITLE>
<SCRIPT>
function loadfile(whatfile) {
parent.myframe.location = whatfile + ".htm";
}
</SCRIPT>
</HEAD>
<BODY>
<DIV onclick = "loadfile('file1')" > Load file 1</DIV>
<DIV onclick = "loadfile('file2')" > Load file 2</DIV>
<DIV onclick = "loadfile('file3')" > Load file 3</DIV>
</BODY>
</HTML>
Manoj K.
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date