var url=document.form1.txt.value;
                parent.main.location.href=url;
直接这样你试试:
                parent.main.location.href=form1.txt.value;

解决方案 »

  1.   

    <html>
        <head>
            <script>
                function openFile()
                {
                    var url=document.form1.txt.value;
                    document.getElementById("main").src = url.indexOf("http://") >= 0 ? url : "http://" + url;
                }
                function clearFile()
                {
                    document.getElementById("main").src = "about:blank";
                }
                function writeSome()
                {
                    var colorValue = document.form1.colors.options[document.form1.colors.selectedIndex].value;
                    var fontValue = document.form1.fontsizes.options[document.form1.fontsizes.selectedIndex].value;
                    var typeValue = document.form1.fonttype.options[document.form1.fonttype.selectedIndex].value;                alert(colorValue+fontValue+typeValue);

     var url=document.form1.txt.value;
    document.getElementById("main").contentWindow.document.write("<font style='color:"+colorValue+"; font-size:"+fontValue+"; font-family:"+typeValue+"'>"+url+"</font>"+"<br/>");
                    //parent.main.document.write("<font color="+colorValue+" size="+fontValue+" face='"+typeValue+"'>"+url+"</font>"+"<br/>");//就在这边,明明值传过来了,可是结果只有颜色改变,其余的都不变!
                }
            </script>
        </head>
        <body>
            <form name="form1">
                URL:<input type="text" name="txt">&nbsp;
                <input type="button" value="打开网页" onClick="openFile();">&nbsp;
                <input type="button" value="清空网页" onClick="clearFile();">&nbsp;
                <input type="button" value="向网页中写入文字" onClick="writeSome();">
                <select name="colors">
                    <option value="red" >red</option>
                    <option value="blue">blue</option>
                    <option value="green">green</option>
                    <option value="yellow">yellow</option>
                </select>
                <select name="fontsizes">
                    <option value="10.5pt">五号</option>
                    <option value="9pt">小五</option>
                    <option value="14pt">四号</option>
                    <option value="12pt">小四</option>
                </select>
                <select name="fonttype">
                    <option value="幼园">幼园</option>
                    <option value="宋体">宋体</option>
                    <option value="楷体">楷体</option>
                    <option value="仿宋">仿宋</option>
                </select>
                <iframe name="main" id="main" width="700" height="500" frameborder="0"></iframe>
            </form>
        </body>
    </html>