PDA

View Full Version : Directly printing a Window without opening a new browser window



prijithkr
4 Oct 2012, 6:07 AM
gLSTEMP is a window.Window, i want to print it directly with out opening it in a new browser window like the below mention option, any idea?




var targetElement = Ext.getCmp('gLSTEMP');
var myWindow = window.open('');
myWindow.document.write('<html><head>');
myWindow.document.write('<title>' + 'Title' + '</title>');
myWindow.document.write('<link rel="Stylesheet" type="text/css" href="http://dev.sencha.com/deploy/ext-4.0.1/resources/css/ext-all.css" />');
myWindow.document.write('<script type="text/javascript" src="http://dev.sencha.com/deploy/ext-4.0.1/bootstrap.js"></script>');
myWindow.document.write('</head><body>');
myWindow.document.write(targetElement.body.dom.innerHTML);
myWindow.document.write('</body></html>');
myWindow.print();

Elfayer
4 Oct 2012, 6:15 AM
I think it' s because of your "window.open()", see : http://www.w3schools.com/jsref/met_win_open.asp

Try name : "_self"

metalinspired
4 Oct 2012, 9:08 AM
@Elfayer
You missed what he is asking :)

@prijithkr
Don't mean to be offensive but you really should use Google first because it would turn up this (http://stackoverflow.com/a/2618980) in first few results.

prijithkr
4 Oct 2012, 7:04 PM
Hi... No Probs @metalinspired
i did try Google and all i got is to open a new window and then call window.print() and if i need to print a pop up window, its a floating component, and self print, will print the current page elements and not the pop up content...

any help?

metalinspired
4 Oct 2012, 10:54 PM
CSS is the only option you have but making it work might be a nightmare.
I would stick to new browser window.