JavaScript学习要点(八)

采用alert()、confirm()、prompt()方法可以调用系统对话框向用户展示消息

confirm()对话框会有OK和Cancel两个按钮,OK返回true,Cancel返回false

prompt()会生成一个提示框,提示用户输入文本,有OK和Cancel,选择OK返回输入内容,选择其他的返回Null

location对象用来返回当前窗口中加载文档的有关信息,


function getQueryStringArgs(){
    var qs = (location.search.length > 0 ? location.search.substring(1) : "");
    args = {};
    items = qs.length ? qs.split("&") : [];
    item = null;
    value = null;
    name = null;

    i = 0;
    len = item.length;

    for (i = 0; i < len; i++) {
        item = items[i].split("=");
        name = decodeURIComponent(item[0]);
        value = decodeURIComponent(item[1]);

        if (name.length) {
            args[name] = value;
        }
    }

    return args;
}

使用location对象的位置操作可以改变浏览器的位置
location.href = “URL” //立即打开新URL


调用location的replace方法,不会产生历史纪录,无法后退

navigator方法



可通过遍历navigator的plugins数组来检测插件
但在IE中无效



history对象用来前进和后退
history.go(1);
history.go(-1);
history.go(2);

也可以传给这个函数一个字符串参数,会跳转到包含该字符串的第一个位置,可能前进也可能后退

history.back();
history.forward();
也可实现前进与后退





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值