473,761 Members | 5,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ot javascript question

e
I've been having an extremely difficult time finding an answer to this in IE
/ js groups, so I thought I'd try here.

I've got an aspx page that delivers loads of report data into custom-named
<span> tags on the client, hidden from the screen by @media classes. From a
dynamically built menu of what was returned, the user selects wich report
they want to view/print and a little jscript .innerHTML magic happens under
the hood that copies the appropriate pages from the main report data into
another tag that they can see & print, it's been assigned a different @media
class. Subsequently they want to print it, so they hit the on-screen print
icon I provide for them, which simply performs a windows.print() .
Everything works great up until that point; windows.print() just does
absolutely nothing. Not even an error. I did a general windows.print() test
on a dummy html page and the print dialog came up fine, so I suspect this
all has something to do with all the .innerHTML shifting I'm doing under the
hood? I have no idea, the lack of documentation for windows.print is diving
me insane, and I can't find anyone talking about a similar problem. Anyone
encountered this before?
Nov 17 '05 #1
7 1681
What happens when you try to print via IE instead of your print button? If
it prints OK, check to see if you have an element named "print" on your
page. I remember encountering interesting problems with this a couple of
years ago, although I can't remember which browser(s) were affected or
exactly how the problem manifested. I do, however, remember that it took
forever to find the problem, which makes me suspect I wasn't seeing any
javascript errors either.

HTH,
Nicole
"e" <e@e.com> wrote in message news:pu******** ************@sp eakeasy.net...
I've been having an extremely difficult time finding an answer to this in IE / js groups, so I thought I'd try here.

I've got an aspx page that delivers loads of report data into custom-named
<span> tags on the client, hidden from the screen by @media classes. From a dynamically built menu of what was returned, the user selects wich report
they want to view/print and a little jscript .innerHTML magic happens under the hood that copies the appropriate pages from the main report data into
another tag that they can see & print, it's been assigned a different @media class. Subsequently they want to print it, so they hit the on-screen print icon I provide for them, which simply performs a windows.print() .
Everything works great up until that point; windows.print() just does
absolutely nothing. Not even an error. I did a general windows.print() test on a dummy html page and the print dialog came up fine, so I suspect this
all has something to do with all the .innerHTML shifting I'm doing under the hood? I have no idea, the lack of documentation for windows.print is diving me insane, and I can't find anyone talking about a similar problem. Anyone encountered this before?

Nov 17 '05 #2
e
Using IE's file->print menu produces a correct result; the print dialog
comes up, and it only prints the corresponding @media areas that are
supposed to print - it does exactly what I want. And for what it's worth,
file->Print preview looks good too. I don't have any elements named
'print'... I have one called 'toPrint'... but that's as close as it comes.

MSDN's comment on window.print() is that it's synonymous to the user
selecting file->print, so; given file->print is working and window.print()
is not, I'm just plain stumped and confused at this point.

"Nicole Calinoiu" <ni*****@somewh ere.net> wrote in message
news:uJ******** ******@TK2MSFTN GP10.phx.gbl...
What happens when you try to print via IE instead of your print button? If it prints OK, check to see if you have an element named "print" on your
page. I remember encountering interesting problems with this a couple of
years ago, although I can't remember which browser(s) were affected or
exactly how the problem manifested. I do, however, remember that it took
forever to find the problem, which makes me suspect I wasn't seeing any
javascript errors either.

HTH,
Nicole
"e" <e@e.com> wrote in message news:pu******** ************@sp eakeasy.net...
I've been having an extremely difficult time finding an answer to this in IE
/ js groups, so I thought I'd try here.

I've got an aspx page that delivers loads of report data into
custom-named <span> tags on the client, hidden from the screen by @media classes. From a
dynamically built menu of what was returned, the user selects wich

report they want to view/print and a little jscript .innerHTML magic happens

under
the hood that copies the appropriate pages from the main report data into another tag that they can see & print, it's been assigned a different

@media
class. Subsequently they want to print it, so they hit the on-screen

print
icon I provide for them, which simply performs a windows.print() .
Everything works great up until that point; windows.print() just does
absolutely nothing. Not even an error. I did a general windows.print()

test
on a dummy html page and the print dialog came up fine, so I suspect this all has something to do with all the .innerHTML shifting I'm doing under

the
hood? I have no idea, the lack of documentation for windows.print is

diving
me insane, and I can't find anyone talking about a similar problem.

Anyone
encountered this before?


Nov 17 '05 #3
The problem almost certainly doesn't lie with window.print() if you can
actually print this via IE. There's something in your page
html/css/javascript that is causing window.print() to not execute correctly.
Unless you're willing to post a sample of the page that isn't working,
you'll probably need to resort to debugging this in little steps. Working
against a copy of the generated html page, take something out, see if it
works, take something else out, test again, etc...

"e" <e@e.com> wrote in message news:5f******** ************@sp eakeasy.net...
Using IE's file->print menu produces a correct result; the print dialog
comes up, and it only prints the corresponding @media areas that are
supposed to print - it does exactly what I want. And for what it's worth,
file->Print preview looks good too. I don't have any elements named
'print'... I have one called 'toPrint'... but that's as close as it comes.

MSDN's comment on window.print() is that it's synonymous to the user
selecting file->print, so; given file->print is working and window.print()
is not, I'm just plain stumped and confused at this point.

"Nicole Calinoiu" <ni*****@somewh ere.net> wrote in message
news:uJ******** ******@TK2MSFTN GP10.phx.gbl...
What happens when you try to print via IE instead of your print button?

If
it prints OK, check to see if you have an element named "print" on your
page. I remember encountering interesting problems with this a couple of
years ago, although I can't remember which browser(s) were affected or
exactly how the problem manifested. I do, however, remember that it took forever to find the problem, which makes me suspect I wasn't seeing any
javascript errors either.

HTH,
Nicole
"e" <e@e.com> wrote in message

news:pu******** ************@sp eakeasy.net... I've been having an extremely difficult time finding an answer to this in
IE
/ js groups, so I thought I'd try here.

I've got an aspx page that delivers loads of report data into custom-named <span> tags on the client, hidden from the screen by @media classes. From
a
dynamically built menu of what was returned, the user selects wich

report they want to view/print and a little jscript .innerHTML magic happens

under
the hood that copies the appropriate pages from the main report data into another tag that they can see & print, it's been assigned a different

@media
class. Subsequently they want to print it, so they hit the on-screen

print
icon I provide for them, which simply performs a windows.print() .
Everything works great up until that point; windows.print() just does
absolutely nothing. Not even an error. I did a general
windows.print() test
on a dummy html page and the print dialog came up fine, so I suspect this all has something to do with all the .innerHTML shifting I'm doing

under the
hood? I have no idea, the lack of documentation for windows.print is

diving
me insane, and I can't find anyone talking about a similar problem.

Anyone
encountered this before?



Nov 17 '05 #4
E
I'll post a sample from the office monday. Here's something interesting I
found though, in the meantime on my laptop at home, just using winxp pro,
ie6 and notepad:

<html><body><he ad><title>test js page</title>
<script language=javasc ript>
function myTest()
{
newWin = window.open('', 'newwindow');
newWin.document .write('Hello') ;
newWin.print();
}
</script></head>
<body>
<a href="javascrip t: myTest()">test it</a>
</body>
</html>

The above sample will recreate my problem. You can comment/remove the
document.write line to have the .print method fire correctly. I don't know
if this is an "undocument ed feature", a bug, or what. Now this is a bit of
a misleading experiment in that I'm not ever actually using document.write
in my application at work; it's all .innerHTML changes in that case. Never
the less, this sample reproduces the "silent-failure" of the print method
I'm encountering, so I suspect whatever is 'breaking' the print method in
this scenario is related to my problem at work.

"Nicole Calinoiu" <ni*****@somewh ere.net> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
The problem almost certainly doesn't lie with window.print() if you can
actually print this via IE. There's something in your page
html/css/javascript that is causing window.print() to not execute correctly. Unless you're willing to post a sample of the page that isn't working,
you'll probably need to resort to debugging this in little steps. Working
against a copy of the generated html page, take something out, see if it
works, take something else out, test again, etc...

"e" <e@e.com> wrote in message

news:5f******** ************@sp eakeasy.net...
Using IE's file->print menu produces a correct result; the print dialog
comes up, and it only prints the corresponding @media areas that are
supposed to print - it does exactly what I want. And for what it's worth,
file->Print preview looks good too. I don't have any elements named
'print'... I have one called 'toPrint'... but that's as close as it comes.
MSDN's comment on window.print() is that it's synonymous to the user
selecting file->print, so; given file->print is working and window.print() is not, I'm just plain stumped and confused at this point.

"Nicole Calinoiu" <ni*****@somewh ere.net> wrote in message
news:uJ******** ******@TK2MSFTN GP10.phx.gbl...
What happens when you try to print via IE instead of your print button?
If
it prints OK, check to see if you have an element named "print" on
your page. I remember encountering interesting problems with this a couple

of years ago, although I can't remember which browser(s) were affected or
exactly how the problem manifested. I do, however, remember that it took forever to find the problem, which makes me suspect I wasn't seeing any javascript errors either.

HTH,
Nicole
"e" <e@e.com> wrote in message

news:pu******** ************@sp eakeasy.net...
> I've been having an extremely difficult time finding an answer to this in
IE
> / js groups, so I thought I'd try here.
>
> I've got an aspx page that delivers loads of report data into

custom-named
> <span> tags on the client, hidden from the screen by @media classes.

From
a
> dynamically built menu of what was returned, the user selects wich

report
> they want to view/print and a little jscript .innerHTML magic
happens under
> the hood that copies the appropriate pages from the main report data

into
> another tag that they can see & print, it's been assigned a different @media
> class. Subsequently they want to print it, so they hit the on-screen print
> icon I provide for them, which simply performs a windows.print() .
> Everything works great up until that point; windows.print() just does > absolutely nothing. Not even an error. I did a general

windows.print() test
> on a dummy html page and the print dialog came up fine, so I suspect

this
> all has something to do with all the .innerHTML shifting I'm doing under the
> hood? I have no idea, the lack of documentation for windows.print is diving
> me insane, and I can't find anyone talking about a similar problem.
Anyone
> encountered this before?
>
>



Nov 17 '05 #5
Um... <html><body><he ad>... Interesting. <g>

There does seem to be a problem with window.print after using
document.write, at least on an empty page. That said, there is no similar
problem when using innerHTML on the body element. Try testing with the page
below:

<html>
<head>
<title>Printi ng tests</title>

<script language=javasc ript>
<!--
function testPrint(testT ype, doInnerHTML, doDocumentWrite )
{
var url;

switch (testType)
{
case 1:
{
url = window.location .href;
break;
}
case 2:
{
url = 'http://www.microsoft.c om/';
break;
}
case 3:
{
url = '';
break;
}
}

var newWin = window.open(url , 'newwindow',
'width=300,heig ht=300');

if (doInnerHTML)
{
newWin.document .body.innerHTML = 'innerHTML';

window.alert(ne wWin.document.d ocumentElement. outerHTML);
}

if (doDocumentWrit e)
{
newWin.document .write('documen t.write');

window.alert(ne wWin.document.d ocumentElement. outerHTML);
}

window.alert('C lick OK to try printing');
try
{
newWin.focus();
newWin.print();
}
catch (e)
{
window.alert(e. description);
}

newWin.close();
window.focus();
}

//-->
</script>

</head>
<body>
<a href="javascrip t: testPrint(1);"> Test on site</a>
<br>
<a href="javascrip t: testPrint(2);"> Test XSS</a>
<br>
<a href="javascrip t: testPrint(3);"> Test empty URL</a>
<br>
<a href="javascrip t: testPrint(3, true);">Test empty URL with innerHTML</a>
<br>
<a href="javascrip t: testPrint(3, false, true);">Test empty URL with
document.write</a>
</body>
</html>

"E" <e@noreply.co m> wrote in message
news:Ot******** ************@sp eakeasy.net...
I'll post a sample from the office monday. Here's something interesting I
found though, in the meantime on my laptop at home, just using winxp pro,
ie6 and notepad:

<html><body><he ad><title>test js page</title>
<script language=javasc ript>
function myTest()
{
newWin = window.open('', 'newwindow');
newWin.document .write('Hello') ;
newWin.print();
}
</script></head>
<body>
<a href="javascrip t: myTest()">test it</a>
</body>
</html>

The above sample will recreate my problem. You can comment/remove the
document.write line to have the .print method fire correctly. I don't know if this is an "undocument ed feature", a bug, or what. Now this is a bit of a misleading experiment in that I'm not ever actually using document.write
in my application at work; it's all .innerHTML changes in that case. Never the less, this sample reproduces the "silent-failure" of the print method
I'm encountering, so I suspect whatever is 'breaking' the print method in
this scenario is related to my problem at work.

"Nicole Calinoiu" <ni*****@somewh ere.net> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
The problem almost certainly doesn't lie with window.print() if you can
actually print this via IE. There's something in your page
html/css/javascript that is causing window.print() to not execute

correctly.
Unless you're willing to post a sample of the page that isn't working,
you'll probably need to resort to debugging this in little steps. Working
against a copy of the generated html page, take something out, see if it
works, take something else out, test again, etc...

"e" <e@e.com> wrote in message

news:5f******** ************@sp eakeasy.net... Using IE's file->print menu produces a correct result; the print dialog comes up, and it only prints the corresponding @media areas that are
supposed to print - it does exactly what I want. And for what it's worth, file->Print preview looks good too. I don't have any elements named
'print'... I have one called 'toPrint'... but that's as close as it comes.
MSDN's comment on window.print() is that it's synonymous to the user
selecting file->print, so; given file->print is working and window.print() is not, I'm just plain stumped and confused at this point.

"Nicole Calinoiu" <ni*****@somewh ere.net> wrote in message
news:uJ******** ******@TK2MSFTN GP10.phx.gbl...
> What happens when you try to print via IE instead of your print button? If
> it prints OK, check to see if you have an element named "print" on your > page. I remember encountering interesting problems with this a couple
of
> years ago, although I can't remember which browser(s) were affected
or > exactly how the problem manifested. I do, however, remember that it

took
> forever to find the problem, which makes me suspect I wasn't seeing

any > javascript errors either.
>
> HTH,
> Nicole
>
>
> "e" <e@e.com> wrote in message
news:pu******** ************@sp eakeasy.net...
> > I've been having an extremely difficult time finding an answer to this in
> IE
> > / js groups, so I thought I'd try here.
> >
> > I've got an aspx page that delivers loads of report data into
custom-named
> > <span> tags on the client, hidden from the screen by @media classes. From
> a
> > dynamically built menu of what was returned, the user selects wich
report
> > they want to view/print and a little jscript .innerHTML magic happens > under
> > the hood that copies the appropriate pages from the main report data into
> > another tag that they can see & print, it's been assigned a different > @media
> > class. Subsequently they want to print it, so they hit the on-screen > print
> > icon I provide for them, which simply performs a windows.print() .
> > Everything works great up until that point; windows.print() just does > > absolutely nothing. Not even an error. I did a general

windows.print()
> test
> > on a dummy html page and the print dialog came up fine, so I suspect this
> > all has something to do with all the .innerHTML shifting I'm doing

under
> the
> > hood? I have no idea, the lack of documentation for windows.print is > diving
> > me insane, and I can't find anyone talking about a similar problem. > Anyone
> > encountered this before?
> >
> >
>
>




Nov 17 '05 #6
E

"Nicole Calinoiu" <ni*****@somewh ere.net> wrote in message
news:ei******** ******@tk2msftn gp13.phx.gbl...
Um... <html><body><he ad>... Interesting. <g>
woops :p
There does seem to be a problem with window.print after using
document.write, at least on an empty page. That said, there is no similar
problem when using innerHTML on the body element.


One of the things I tried before was to spawn a new window, body.innerHTML
some text and .print(), which actually did work; sort of. An issue with CSS
arose: the browser doesn't seem to cascade style data when it's supplied via
body.innerHTML to a new window. I tried <link> & <style> as part of the
..innerHTML text, but neither did the trick - the data in the new window was
not affected by the style information. And unfortunately, I need those
styles to be applied, esp. the @media ones. The only way I could get the
styles applied in the new window was to document.write, and that of course
put me right back at square 1 ( and lead me to discover that document.write
issue in my previous post ).
Nov 17 '05 #7
Well, the document.write -> no window.print thing does seem to something of
a bug. Why don't you circumvent it by using a saved html page as the
"blank" page, with the CSS link or style attribute pre-applied? This would
circumvent the need for using document.write and, hopefully, resolved the
printing problem.

HTH,
Nicole
"E" <e@noreply.co m> wrote in message
news:L-*************** *****@speakeasy .net...

"Nicole Calinoiu" <ni*****@somewh ere.net> wrote in message
news:ei******** ******@tk2msftn gp13.phx.gbl...
Um... <html><body><he ad>... Interesting. <g>
woops :p
There does seem to be a problem with window.print after using
document.write, at least on an empty page. That said, there is no similar problem when using innerHTML on the body element.


One of the things I tried before was to spawn a new window, body.innerHTML
some text and .print(), which actually did work; sort of. An issue with

CSS arose: the browser doesn't seem to cascade style data when it's supplied via body.innerHTML to a new window. I tried <link> & <style> as part of the
.innerHTML text, but neither did the trick - the data in the new window was not affected by the style information. And unfortunately, I need those
styles to be applied, esp. the @media ones. The only way I could get the
styles applied in the new window was to document.write, and that of course
put me right back at square 1 ( and lead me to discover that document.write issue in my previous post ).

Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.