javascript问题,关于重构window.alert()后,然后调用window原本的window.alert()的方法

大神们,问个问题,如果在script标签的第一行散写,重构了window.alert()的方法,如果不动上面重构的代码的基础上,只能用一条语句直接调用原本的window.alert()的方法,有办法么?
 

 

 
window.alert = window.constructor.prototype.alert
追问
问题解决了,非常感谢
 
 

我的理解是这样的。

1
2
3
4
5
6
7
window._alert = window.alert //临时保存一下;
window.alert = function(){
    //写你重构的方法;
    return;
}
//下面你想恢复的话就很简单了
window.alert = window._alert;
 
 
 
 
 
 
本回答被网友采纳
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
<html>
    <head>
        <title>aa</title>
        <script type="text/javascript">
              var userName;
              function greetUser() {
                alert('Hello, I am your pet rock.');
              }
        </script>
    </head>
    <body onload="greetUser();"></body>
</html>

javascript 重构alert()的更多相关文章

  1. javascript的alert()的消息框不弹出或者弹出信息有误

    有时不知道什么,有时javascript的alert()的消息框不弹出或者弹出信息有误,代码是这么写的: //提示信息 public static void alert(TemplateControl ...

  2. Javascript中alert</script>的方法

    Javascript中alert</script>的方法: <%@ page language="java" import="java.util.*&q ...

  3. webform运行时弹出JavaScript的alert窗口

    https://stackoverflow.com/questions/9720143/asp-net-web-application-message-box Or create a method l ...

  4. 重构alert,confirm

    最近写了一个重构的alert,confirm控件,调用时直接使用alert,confirm即可 //调用方法 alert("提示语") window.confirm('你确定要删除 ...

  5. Javascript:alert(1)可以这样写以绕过filter

    在2011年的BlackHat DC 2011大会上Ryan Barnett给出了一段关于XSS的示例javascript代码: ($=[$=[]][(__=!$+$)[_=-~-~-~$]+({}+ ...

  6. 怎么使用response.write来做一个javascript的alert弹出窗口

    Page.RegisterStartupScript("alert", "<script language=javascript>alert('添加成功'); ...

  7. PHP输出javascript,alert中文乱码解决办法

    echo '<html><head><meta http-equiv="Content-Type" content="text/html; ...

  8. javascript中alert()与console.log()的区别

    我们在做js调试的时候使用 alert 可以显示信息,调试程序,alert 弹出窗口会中断程序, 如果要在循环中显示信息,手点击关闭窗口都累死.而且 alert 显示对象永远显示为[object ]. ...

  9. javascript在alert()出现中文乱码

    今天在写jquery代码时,alert()总是出现中文乱码 琢磨了好一会儿,在网上查的资料是html页面上设置charset为GB2312 <meta charset="GB2312& ...

随机推荐

  1. C# 集合转换为DataTable

    该类就用了几个类型,如int,int?,string,所以其它类型就先没管. 用到的类: public class tb_Projects { public int ProID { get; set; ...

  2. Python自动化运维开发实战 一、初识Python

    导语 都忘记是什么时候知道python的了,我是搞linux运维的,早先只是知道搞运维必须会shell,要做一些运维自动化的工作,比如实现一些定时备份数据啊.批量执行某个操作啊.写写监控脚本什么的. ...

  3. hive\hadoop 常用命令

    —1—————— 后台跑程序语句: 在shell下输入: nohup hive -f  aaa.sql >bbb.log 2>&1 & 然后把sql 的脚本导入服务器上:T ...

  4. Displacement Mapping

    [Displacement Mapping] Displacement Mapping(移位贴图). Normal maps的另一个应用是displacement mapping,在这个应用中,细节的 ...

  5. node-pre-gyp install --fallback-to-build 错误

    [node-pre-gyp install --fallback-to-build 错误] npm install bcrypt时遇上错误 此时,安装node-gyp npm install -g n ...

  6. js中switch/case分支的值可以是变量或表达式

    在一些高级语言如C#中,switch分支的值只能是常量,而js中可以是变量或表达式: <!DOCTYPE html> <html lang="en"> &l ...

  7. 手工命令行 搭建 hadoop 和 spark 环境

    环境准备:3台CentOS7,64位,Hadoop2.7需要64位Linux 192.168.20.161  192.168.20.162  192.168.20.163 三台机器分别叫host01. ...

  8. love is ... ...

    16 years old, love is dream.20 years old, love is sex.30 years old, love is marriage. 40 years old, ...

  9. scrapy 异步存储mysql

    1.在setting中设置MySQL连接信息 HOST='101.201.70.139'MYSQL_DBNAME='anttest'MYSQL_PASSWORD='Myjr678!@#'MYSQL_U ...

  10. python 函数的动态参数 命名空间,作用域以及函数嵌套,global和nonlocal (重点)

    *** 坚持坚持,即使你不太强*** 1.函数的动态传参 2.函数的命名空间及作用域 3.函数嵌套 4.global和nonlocal关键字 一.函数的动态传参 1. *args: 位置参数动态传参, ...