2011-04-18 17 views
0

我應該在window.onload函數中使用window.open()函數。如果不是如何使用window.onload =「url」。請告訴我一些例子。下面是我正在嘗試做的事情。文本VA; idation工作正常。當我輸入字符串運行其不會打開evovle.jsp(關注URL)如何在window.load函數中使用window.open事件

例如:在evolve.jsp
防爆 evolve.jsp

<html> 

<head> 
<script type="text/javascript"> 
function validatetxtbox() 
{  var txtfield;  
    txtfield =document.getElementById('txtbox').value; 
     if(txtfield == "run") 
    { alert("you entered string right"); 

window.onload=function(){window.open('evolve.jsp''welcome' 'width=500,height=500,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes');}   
} 
else { alert("Try again"); } 
}  
</script> 
</head> 

<body> 
<input type="text" id="txtbox" maxlength="3"> 
<input type="button" id="btn" value="Send" onclick="validatetxtbox()"> 

</body> 
</html> 

回答

0
<html> 
<head> 
<script ="text/javascript"> 
    function check() { 
var txtfield; txtfield =document.getElementById('txtbox').value; 
if(txtfield == "run") 
{ alert("you entered string right"); 
var newwin=window.open('evolve.jsp','welcome','width=500,height=500,menubar=yes,status=yes,location=yes,toolbar=yes'); 
newwin.focus(); 
} 
else { alert("Try again"); } 
    } 
</script> 
    </head> 
    <body> 
    Enter a Keayword 
    <input type="text" id="txtbox" onblur="check()" /> 
    </body> 
</html> 
+0

非常感謝您的快速回復... madhav!而不是onblur我不能使用onclick ...按鈕。 – hari 2011-04-18 07:13:57

+0

@hari如果你有一個按鈕,你可以使用onclick事件調用相同的方法,它將會產生相同的意義 – Maddy 2011-04-18 11:13:56

0

使用查詢字符串,並檢查#alertme

相關問題