[thelist] Javascript: printing and executing?

Joshua Earl jearl at adel.tafe.sa.edu.au
Tue Feb 20 18:40:25 CST 2001


Hey all,

What I am trying to do is pop a window with javascript with a given
document in it, with no buttons location or anything, and javascript
print and close buttons. This site is an educational one for young
kids and the client is worried that kids will get lost if we make it
look like the window is a completely new one, although they will not
let us open the exercise in the same window.

So I thought the best solution would be to pop a new window, with no
buttonbar, status, location etc...ans javascript a print and close
button. However, I'm finding that the print button isn't working how I
would like it to.

I'm working on a Mac, site is for IE5 or NN4 on mac and windows.

I began by coding it like this;

<a href="#" onClick="javascript:window.print()">print this window</a> 

with mixed results.

then I tried putting it into a function and calling that from the
onClick event. 

no dice.

the javascript:window.close() works fine. on both platforms and browsers.

It seems that printing windows in general have mixed results,
sometimes even the Print button on the browser button bar works
inconsistently (when that window is created using javascript).

I have a feeling something is going on here, and that it has something
to do with the deeper workings of Javascript, and once I get it, I'll
be crusing.

-----

The other thing I want to know is this.

If I pass a variable to a function like this;

onClick ="doStuff('print')"

and then assemble the property in the function by doing something like;

function doStuff(command) {
stuff = "window."+command+"()";
}

how do I get the browser to DO stuff?

ie stuff = "window.print()"

how do I get the print command to happen?

I will appreciate any help anyone can give me on this, I'm feeling
like I'm up against a bit of a wall.

Seeya,

Josh




More information about the thelist mailing list