我有以下代码,但它在新窗口中重定向url但我无法使用iframe在同一窗口中加载它。请修改它并帮助我。
<script type='text/javascript'>
function redirect(name="action") {
//look for text inside the NEW textbox
var input = document.getElementById('query').value.toLowerCase();
switch(input) {
case 'keyword1':
//put this to see if this code runs
//alert("Test");// UNCOMMENT THIS
window.location.replace('page1.html');
break;
case 'keyword2':
window.location.replace('page2.html');
break;
default://
return true;
break;
}
return false;//don't let the form submit
}
</script>
<form action="search/search.php" method="get"onsubmit='return redirect();'>
<input type="text" name="query" id="query" value="SEARCH" columns="2"
autocomplete="off" delay="1500"
onfocus="if(this.value==this.defaultValue)this.value=''"
onblur="if(this.value=='')this.value=this.defaultValue" >
<input type="submit" value="" id="submit">
<input type="hidden" name="search" value="1">
</form>
答案 0 :(得分:0)
你有没有理由使用
window.location.replace('page1.html');
你能试试吗
window.location.href('page1.html');