如何判斷輸入地址為空,prompt的str2如何獲取
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?
? <script type="text/javascript">??
? ??
? ? ? ? var sina=confirm("是否打開:");
? ? ? ?if(sina==true){
? ? ? ? ? ?var a=""
? ? ? ?var v1=prompt("請(qǐng)輸入網(wǎng)址",a);
? ? ? ?if(a!=null){
? ? ? alert(v1);
? ? ? window.open(v1,'width=400,height=500,toolbar=no,menubar=no');}
? ? ? else{
? ? ? ?alert("hello");}}
? ? ? ?else{
? ? ? ?window.close();
? ? ? ?}
2024-01-05
var sina=confirm("是否打開:");
? ? ? ?if(sina==true){
? ? ? ? ? ?var a="http://idcbgp.cn"
? ? ? ?var v1=prompt("請(qǐng)輸入網(wǎng)址",a);//prompt的str2值可以自己手動(dòng)輸入,也可以設(shè)置默認(rèn)值,也就是這里的變量a=地址
? ? ? ?if(v1!=null){//這里的判斷用prompt方法的返回值v1!=null來判斷,v1的值就是輸入的地址
? ? ? alert(v1);
? ? ? window.open(v1,'width=400,height=500,toolbar=no,menubar=no');}