By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,780 Members | 1,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

open file script

P: n/a
Another problem with the browser-based WYSIWYG editor I'm trying to
assemble using IE's design mode.

This opens the selected page in the editor iframe named iView:

<select name="template"
onChange="window.open(this.options[this.selectedIndex].value,'iView')">
<option>TEMPLATES</option>
<option value="template1.htm">Template 1</option>
<option value="template2.htm">Template 2</option>
etc.

But I also want a button to open any html file selected from the
user's hard drive. This opens the browse-selected page in a whole new
window rather than in the iframe of the editor:

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function whatFile() {
window.location = 'file:///' + document.form1.cmuds.value,'iView';
}
// End -->
</script>
</head>
<body onLoad="Init()"> [Note: this places iframe in IE design mode]
<form name="form1" method="get">
<p><input type="file" name="cmuds"><input type="button" value="Open
File" onclick="whatFile()"></form>
<iframe src="frame1.htm" name="iView" width="400"
height="300"></iframe>

I've tried substituting window.open for window.location or placing it
elsewhere in the script, but nothing works to open the browse-selected
page in the iframe. I suspect the solution is relatively simple -- an
extra line or two of script -- but I'm such a javascript dummy I can't
find it using my muddling trial-and-error method.
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
William Starr Moake wrote:
<snip>
I've tried substituting window.open for window.location or placing it
elsewhere in the script, but nothing works to open the browse-selected
page in the iframe.


try this (a function was removed from body onload to test this code):

<SCRIPT type="text/javascript">
function whatfile() {
document.frames['iView'].location.href= document.form1.cmuds.value;
}
</script>

.....

<body>
[Note: this places iframe in IE design mode]
<br>
<br>
<form name="form1" method="get">
<p>Select File to Load <input type="file" name="cmuds">
<p>Load Document in Iframe <input type="button" value="Open File"
onclick="whatfile()">
</form>
<br>
<br>
<iframe src="frame1.htm" name="iView" id="iView" width="400"
height="300"></iframe>
</body>

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.