字体设置 var url=document.form1.txt.value; parent.main.location.href=url;直接这样你试试: parent.main.location.href=form1.txt.value; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <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"> <input type="button" value="打开网页" onClick="openFile();"> <input type="button" value="清空网页" onClick="clearFile();"> <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> iframe如何跨域自适应高度 关于js导出table中的数据到excel中的问题。 jquery 如何删除事件? jQuery中如何实现列表顺序的改变? 如何遍历div? 走一走,瞧一瞧 喽!!! (各位js大虾们) javascript读取服务器端html文件 gridview中的checkbox问题 高手进来看看:怎么用js把这种格式的xml转换成另外一种呢? 谁有修改微软IE默认首页的代码呀? 怎么用JS修改CSS文件里面的元素? 支持IE/FIREFOX复制的JS代码
<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">
<input type="button" value="打开网页" onClick="openFile();">
<input type="button" value="清空网页" onClick="clearFile();">
<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>