open file script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • William Starr Moake

    open file script

    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="windo w.open(this.opt ions[this.selectedIn dex].value,'iView') ">
    <option>TEMPLAT ES</option>
    <option value="template 1.htm">Template 1</option>
    <option value="template 2.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="JavaS cript">
    <!-- Begin
    function whatFile() {
    window.location = 'file:///' + document.form1. cmuds.value,'iV iew';
    }
    // 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"><i nput type="button" value="Open
    File" onclick="whatFi le()"></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.
  • mscir

    #2
    Re: open file script

    William Starr Moake wrote:
    <snip>[color=blue]
    > 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.[/color]

    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="whatfi le()">
    </form>
    <br>
    <br>
    <iframe src="frame1.htm " name="iView" id="iView" width="400"
    height="300"></iframe>
    </body>

    Comment

    Working...