Asp classic 不追加文本的弹出窗口

Asp classic 不追加文本的弹出窗口,asp-classic,popupwindow,window.open,Asp Classic,Popupwindow,Window.open,我试图在进入网站时实现一个“跟踪窗口”弹出窗口,然后在整个网站上向该窗口发送消息,以便诊断我在网站上遇到的一些更棘手的问题。 问题在于,如果跟踪窗口已经存在,则页面会发生更改,在添加新的TraceText之前,所有内容都会被删除。 我想要的是一个窗口,可以从网站内的任何页面发送消息 我有一个javascript脚本debugger.js,我将它作为脚本包含在每个屏幕中(如下所示),然后调用sendToTraceWindow()函数向它发送消息,而不考虑网站。由于我目前正在调查的问题,目前这主要是

我试图在进入网站时实现一个“跟踪窗口”弹出窗口,然后在整个网站上向该窗口发送消息,以便诊断我在网站上遇到的一些更棘手的问题。 问题在于,如果跟踪窗口已经存在,则页面会发生更改,在添加新的TraceText之前,所有内容都会被删除。 我想要的是一个窗口,可以从网站内的任何页面发送消息

我有一个javascript脚本debugger.js,我将它作为脚本包含在每个屏幕中(如下所示),然后调用sendToTraceWindow()函数向它发送消息,而不考虑网站。由于我目前正在调查的问题,目前这主要是在vbscript中完成的。 我想这是因为我在debugger.js中编写脚本到每个屏幕,设置traceWindow变量=null(见下面的代码),但我不知道如何解决这个问题

非常感谢您的帮助。 安德鲁

代码示例:

debugger.js

var traceWindow = null

function opentraceWindow()
{
   traceWindow = window.open('traceWindow.asp','traceWindow','width=400,height=800')
}

function sendToTracewindow(sCaller, pMessage)
{

   try
   {
      if (!traceWindow)
      {
         opentraceWindow()
      }

      if (!traceWindow.closed)
      {
         var currentTrace = traceWindow.document.getElementById('trace').value
         var newTrace = sCaller + ":" + pMessage + "\n" + currentTrace
         traceWindow.document.getElementById('trace').value = newTrace
      }
   }
   catch(e)
   {
         var currentTrace = traceWindow.document.getElementById('trace').value
         var newTrace = "error tracing:" + e.message + "\n" + currentTrace
         traceWindow.document.getElementById('trace').value = newTrace
   }

}
traceWindow.asp-只是一个id='trace'的文本区域:

<HTML>
   <head>
      <title>Debug Window</title>
   </head>
   <body>
      <textarea id="trace" rows="50" cols="50"></textarea>
   </body>
</HTML>

调试窗口

我认为没有任何方法可以避免这样的事实,即每次加载页面时都会重置traceWindow变量,从而使现有窗口的句柄无效。但是,如果您不介意利用LocalStorage和一些jQuery,我相信您可以实现所需的功能

将跟踪窗口更改为:

<html> 
   <head> 
      <title>Debug Window</title> 
      <script type="text/javascript" src="YOUR_PATH_TO/jQuery.js" />
      <script type="text/javascript" src="YOUR_PATH_TO/jStorage.js" />
      <script type="text/javascript" src="YOUR_PATH_TO/jquery.json-2.2.js" />
      <script type="text/javascript">
        var traceOutput;
        var traceLines = [];
        var localStorageKey = "traceStorage";

        $(function() {
          // document.ready.
          // Assign the trace textarea to the global handle.
          traceOutput = $("#trace");
          // load any cached trace lines from local storage
          if($.jStorage.get(localStorageKey, null) != null) {
            // fill the lines array
            traceLines = $.jStorage.get(localStorageKey);
            // populate the textarea
            traceOutput.val(traceLines.join("\n"));
          }
        });

        function AddToTrace(data) {
          // append the new trace data to the textarea with a line break.
          traceOutput.val(traceOutput.val() + "\n" + data);
          // add the data to the lines array
          traceLines[tracelines.length] = data;
          // save to local storage
          $.jStorage.set(localStorageKey, traceLines);
        }

        function ClearTrace() {
          // empty the textarea
          traceOutput.val("");
          // clear local storage
          $.jStorage.deleteKey(localStorageKey);
        }
      </script>
   </head> 
   <body> 
      <textarea id="trace" rows="50" cols="50"></textarea> 
   </body> 
</html>
每次加载新页面并刷新跟踪窗口时,现有跟踪数据都会从本地存储加载并显示在文本区域中。这应该可以实现您想要的功能

请善待任何错误-我将在周一早上发布此消息


查找jQuery库应该很简单。您可以在这里找到jStorage库:,也可以在这里找到jquery json:

您想再次跟踪什么?要诊断什么类型的错误?不一定是错误,但我可能会发现有用的任何跟踪:)。例如,我可能希望在TraceWindow中显示给定时刻的字符串值sStatus,因此可以调用sendToTraceWindow(“window_onmousemove”,iStatus),或者当有人按下“Save”(保存)按钮时,我会将其记录到TraceWindow sendToTraceWindow(“Save_mouseup”,“Save button pressed”(保存按钮按下))。所以不是错误-只是我可能会发现在查找bug时有用的文本。非常好,谢谢brad。它只会在开发环境中“打开”,所以我对本地存储并没有问题。这似乎是个好办法。我以前没有使用过jquery,所以我要试一试!
var traceWindow = null;                 
function opentraceWindow() {                      
  traceWindow = window.open('traceWindow.asp','traceWindow','width=400,height=800');
}

function sendToTracewindow(sCaller, pMessage) {
  traceWindow.AddToTrace(sCaller + ":" + pMessage);
}