Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 17th, 2003, 12:51 PM
Registered User
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Capture ALERT window contents

Is is possible to capture and write to a file the text that would have displayed in an Alert window?

The contents is too large for the Alert window to display completely. I need to see the entire contents.

Can I do this? If so, how please?


Old October 18th, 2003, 05:30 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

If this is for debugging and you have control over the page then yes. You will have to allow ActiveX controls to run. If possible add the site to "Trusted Sites" and permit the ActveX settings at the top of the security settings. You can remove the site later if you wish.
Use the following function:
function Alert(Text)
  var FILE_PATH = "C:\log.txt"; //Change to wherever
  var ForAppending = 8;
  var oFSO = new ActiveXObject("Scripting.FileSystemObject");
  var oTS = oFSO.openTextFile(FILE_PATH, ForAppending, true);
  oTS = null;
  oFSO = null;
and then replace all alert calls with Alert (Capital A).
A simpler solution if you don't need a permanent record is to insert a div in the page with an id of "divMessage" and use:
function Alert(Text)
  document.getElementById("divMessage").innerText = Text;
Another thing is to press alt+SPACEBAR when the large alert box is open and move the alert up the page.


Old October 21st, 2003, 08:41 AM
Registered User
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks Joe, for the quick response. I don't know if your suggestion will work, I didn't try it.

My problem was that there was too much text to fit into an ALERT window and the part of the text I needed to see wasn't being displayed. My first question was...how do I capture the output of an ALERT window? After giving it some thought I realized I didn't necessarily have to use an ALERT window. I instead took the string that was being fed to the ALERT window and wrote it out to a new WINDOW object. That was all I really needed.

I do appreciate the help though. Thanks again.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading contents of other window controls furqanms C# 2005 0 June 15th, 2007 02:04 PM
Centering Popup window & Blur Parent window jkusmanto Javascript How-To 0 May 25th, 2007 03:19 AM
Window refresh and window pop up in Java Script Aleksandra Javascript How-To 2 March 2nd, 2007 06:47 PM
How to capture mouse coordinates in an IE window? APX Visual C++ 1 May 17th, 2005 03:01 AM
"Alert " to remind user to close the window? larry Javascript How-To 2 June 5th, 2004 11:34 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.