Forum Moderators: open

Message Too Old, No Replies

Open File in Designated Frame

         

PaulPA

1:53 am on Jan 4, 2006 (gmt 0)

10+ Year Member



I have two frames named "top" and "bottom". I want the top frame to let a user browse locally for a file (e.g., text file, spreadsheet) that when selected will open in the bottom frame. I'm not strong on javascript but here is some of the information I have so far for what would appear in the top frame:

<script language="JavaScript">
function loadfile(){
file = document.myForm.theFILE.value;
parent.bottom.location = file;
}
</script>

<form name="myForm">
<input type="file" name="theFILE" size="70"><br/>
<input type="submit" value="Send File" onClick="loadfile()">
</form>

Can't seem to get files to load in the bottom frame. I have made sure the files follow the "file:///..." setup but that does not seem to work. Any help is appreciated.

DrDoc

5:33 pm on Jan 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try changing your submit to a
button
type. Also, tack
.href
onto your location assignment.

PaulPA

7:55 pm on Jan 5, 2006 (gmt 0)

10+ Year Member



DrDoc - Thanks for your help but I'm getting nowhere with this. Here are the three files that I'm using to build the frames page. But I get nothing when I try to load a local file (I am manually entering the "file:///" before the selected file name).

frame_main.html
<html>
<frameset rows="30%,80%">
<frame src="test_local_files.html" name="top">
<frame src="bottom_frame_test.html" name="bottom">
</frameset>
</html>

test_local_files.html
<html>
<head>
<script language="JavaScript">
function loadfile(){
file = document.myForm.theFILE.value;
parent.bottom.location.href = file;
}
</script>
</head>
<body>
<form name="myForm">
<input type="file" name="theFILE" size="70"><br />
<input type="button" value="Send File" onClick="loadfile()">
</form>
</body>
</html>

bottom_frame_test.html
<html>
<head></head>
<body>
test frame
</body>
</html>