js点击弹出询问框是否添加至购物车localstorage

JavaScript08

js点击弹出询问框是否添加至购物车localstorage,第1张

是。js点击弹出询问框由于没有本地存储,不会调取数据,因此是添加至购物车localstorage。在点击文件链接的时候,弹出询问框是操作系统本身设置好的,任何一个电脑的IE都一样会弹出。

var uri = "http://www.imooc.com"

window.onload = function () {

if (confirm("是否打开新窗口?"))

{

uri = window.prompt("请输入打开的网址", uri)

if (uri) {

window.open(uri, "_blank", "width=400,height=500,menubar=no,toolbar=no,status=no", true)

}

else {

alert("您输入了空网址!")

}

}

}

弹出提示框一般有3种

1)alert (普通提示框)

2)prompt (可输入的提示框)

3)confirm (可选择的提示框)

下面举个例子:

<!doctype html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>Document</title>

</head>

<body>

<button onclick="mal()">第一种:alert</button>

<button onclick="mpro()">第二种:prompt</button>

<button onclick="mcon()">第三种:confirm</button>

<script>

    function mal(){

        alert('这是一个普通的提示框')

    }

    function mpro(){

        var val = prompt('这是一个可输入的提示框','这个参数为输入框默认值,可以不填哦')

        //prompt会把输入框的值返回给你

    }

    function mcon(){

        var boo = confirm('这是一个可选择的提示框,3种提示方式,学会了吗?')

        //confirm 会返回你选择的选项,然后可以依据选择执行逻辑

        if(boo){

            alert('学会了,真聪明')

        }else{

            alert('再来一遍吧')

        }

    }

</script>

</body>

</html>