Blog Stats
  • Posts - 8
  • Articles - 0
  • Comments - 24
  • Trackbacks - 0

 

Using javascript to Write to a New Child Window

I'm almost embarrassed to put this up because it's so small, but it's something I used to do all the time and had reason to have to re-learn it recently for something I was doing.

Sometimes -- at least until I find a better way -- I need to be able to get "editable" debugging text out of javascript.  Using the "alert" box doesn't work for this because you can't do the ctrl-c trick to get its text.  (For some message boxes, you can hit ctrl-c and it'll copy the contents such that you can put it into notepad.)

Anyway, the javascript below will cause a new window to open and will write whatever you want into it.  Then you can do whatever you would normally do with what shows up in IE windows.  FYI, the contents of the open() method is a double-apostrophe for a required parameter that nevertheless can be empty.

window.open('').document.write('your text here')


Feedback

# re: Using javascript to Write to a New Child Window

Gravatar

If you develop in Firefox with Firebug, you can use console.log('Text') and it will output the text to the Firebug console. You could also use Sys.Debug.trace if you are using ASP.NET AJAX. This will use console.log if present, but it can also write to html elements if they are named properly and it can post back to the server to write in VS Output window if running in debug mode.

4/1/2008 2:44 PM | Shaun

# re: Using javascript to Write to a New Child Window

Gravatar

Along with what Shuan said; Nikhils web development helper also hooks into Sys.Debug.trace and will print out debug info in its' console. I use both FireBug and Nikhil's tool. They've saved my hair line many times over :D

4/2/2008 9:52 AM | Jim L.

# re: Using javascript to Write to a New Child Window

Gravatar

Another option is that if you are using the MS ASP.NET Ajax Client-Side library (AKA MS Ajax), you can use

Sys.Debug.trace("some text");

or

Sys.Debug.traceDump(someObject);

In Firefox, these print to FireFox JS log.  If you are in IE, you can put a textarea on the page called "tracelog" and the messages will appear here.  

The differences in the above calls is that "traceDump" actually dumps out the underlying values of the object, where "trace" prints a message.

4/2/2008 11:15 AM | jkimble

# re: Using javascript to Write to a New Child Window

Gravatar replica watches TAG Heuer Co. has been providing replica watches numerous sporting events with official rolex timekeeping assistance (including the 1920 Olympic Games). Other fake rolex sports competitions supported by TAG Heuer Co.replica watch also include the FIA Formula 1 fake watches World Championship auto fake watches racing (since 1969) and the FIS Ski World Cup (since 1992).omega watches TAG Heuer Co. has also been replica rolex supplying premium mountain resorts with omega their timekeepers and clocks (Colorado,breitling the Vail, French, Italian, Austrian cartier and the Swiss Alps). Moreover,cartier watches TAG HEUER Watches have also tag heuer been connected with automobile races tag heuer for a good while now. TAG Heuer breitling watches made the first car dash armani watches clock in 1911. TAG Heuer has armani sponsored F1 drivers such as Michael Schumacher,audemars piguet Ayrton Senna, Niki Lauda,montblanc watches Jacky Ickx, and Emerson Fittipaldi.patek philippe Besides, the McLaren F1 racing replica watches team has been using TAG Heuer watches since 1986. Tiger Woods rolex watches has recently joined the TAG Heuer supporting team rolex. 3/30/2010 1:18 AM | rolex

# re: Using javascript to Write to a New Child Window

Gravatar replica watches One the most popular categories with rolex watches collectors are the old railroad watches or fake rolex other pocket watches. Pocket watches replica watch have always been more than just watches;fake watches old pocket watches are frequently kept as tag heuer family heirlooms for generations. They breitling watches are valuable. They are known for cartier watches their invincible elegance no matter what patek philippe their monetary value is. Founded by Edouard Heuer omega watches in 1860, TAG Heuer has been a Swiss avant-garde omega watchmaker for almost 150 years. The breitling company based in La Chaux-de-Fonds, Switzerland. The cartier watchmakers of Tag Heuer created innovative stopwatches, chronographs & audemars piguet water resistant models as developing symbols montblanc watches of reliable and durable timekeeping implements. The armani watches founder of the company has set many armani standards for timekeeping. The TAG Heuer team replica watches of skilled worker developed the best novel tag heuer timekeepers, chronographs, and water-tight Replica Watches of the fake rolex day 3/30/2010 1:19 AM | rolex

# re: Using javascript to Write to a New Child Window

Gravatar Its a security thing. It'll work without asking if there is only one location in the browsers history, if theres more than one, it prompts the user for confirmation. If this becomes a problem, you can always restrict the history of a window to one location by using the replace() method, for those browsers that support it. 4/19/2010 2:07 AM | sito di casinò su internet

# re: Using javascript to Write to a New Child Window

Gravatar Try the function below

function funOpenWindow()
{
//Open child window
var var_win = window.open('testChild.html','','scrollb… width=1, status=yes,toolbar=no,menubar=no,locatio…
//variable for child window document loading status
var statusX = '';

do
{
//get the child window document loading status
statusX = var_win.document.readyState;
}
while (statusX !="complete") //continue detect the status if it is not completed yet

//code about what you want to do after the child window finished loading
} 5/21/2010 6:29 PM | bad credit car loan

# re: Using javascript to Write to a New Child Window

Gravatar
I really like this site.
blackhawk holsters
6/2/2010 4:29 AM | ADAm

Post a comment





 

Please add 3 and 3 and type the answer here:

 

 

Copyright © Edward Buatois