f



No content (source code) while using 'window.open' in Mozilla, Opera, Chrome & Safari (source code only visible in IE)

I'd like to offer a print view window which automatically opens the
printer window (Ctrl+P) after it has been loaded.
Unfortunately the printer window (Ctrl+P) doesn't open automatically.
After some troubleshooting I realized that in Mozilla, Opera, Chrome &
Safari there is no source code visible of the print view window. In
Internet Explorer the source code looks fine and if you save the
source code and open the print view page again the printer window (Ctrl
+P) opens automatically.

What's wrong with my code?

Hint: I need to open the print view window in 'print.js' because in my
project the content of the print view window will be generated at the
end of the print.php file (after <body> </body>) so that it's not
possible to put the 'window.open' direct in the 'print.php' file.

Here is an expamle:
  http://test.seekware.ch/print.php

Here is the code of the example:
------------------------------------------------------------------------
print.php
<html>
  <head>
    <script type = "text/javascript" src = "print.js"></script>
  </head>

  <body>
    <a href = "javascript: open_print_window();">Open print window</a>
  </body>
</html>
------------------------------------------------------------------------
print.js
function open_print_window() {
  var print_window;
  var print_content = "<html><body onLoad = 'window.print()'>Sample
text to print</body></html>";
  print_window = window.open("", "", "width = 500");
  print_window.document.write(print_content);
}
------------------------------------------------------------------------

Regards
Seeky
0
seekware (55)
5/6/2012 11:22:09 PM
comp.lang.javascript 38370 articles. 2 followers. javascript4 (1315) is leader. Post Follow

2 Replies
923 Views

Similar Articles

[PageSpeed] 16

On 7/05/2012 9:22 AM, Stefan Mueller wrote:
> I'd like to offer a print view window which automatically opens the
> printer window (Ctrl+P) after it has been loaded.
> Unfortunately the printer window (Ctrl+P) doesn't open automatically.
> After some troubleshooting I realized that in Mozilla, Opera, Chrome&
> Safari there is no source code visible of the print view window. In
> Internet Explorer the source code looks fine and if you save the
> source code and open the print view page again the printer window (Ctrl
> +P) opens automatically.
>
> What's wrong with my code?
>
> Hint: I need to open the print view window in 'print.js' because in my
> project the content of the print view window will be generated at the
> end of the print.php file (after<body>  </body>) so that it's not
> possible to put the 'window.open' direct in the 'print.php' file.
>
> Here is an expamle:
>    http://test.seekware.ch/print.php
>
> Here is the code of the example:
> ------------------------------------------------------------------------
> print.php
> <html>
>    <head>
>      <script type = "text/javascript" src = "print.js"></script>
>    </head>
>
>    <body>
>      <a href = "javascript: open_print_window();">Open print window</a>
>    </body>
> </html>
> ------------------------------------------------------------------------
> print.js
> function open_print_window() {
>    var print_window;
>    var print_content = "<html><body onLoad = 'window.print()'>Sample
> text to print</body></html>";
>    print_window = window.open("", "", "width = 500");
>    print_window.document.write(print_content);
> }
> ------------------------------------------------------------------------

You at least need
   document.close();
See <https://developer.mozilla.org/en/document.write>

Andrew Poulos
0
ap_prog (388)
5/7/2012 3:27:33 AM
Yes, you're right. The following statement was missing:
  print_window.document.close();

Many thanks
Seeky
0
seekware (55)
5/9/2012 12:44:06 AM
Reply:

Similar Artilces:

can't use View, Source menu to open the source code.
Hi, I can't use View, Source menu to open the source code of a page. I am using WinXP and IE 6. Here is the link: http://news.wenxuecity.com/BBSView.php?SubID=news&MsgID=21414 Could you try it? If you can't use View, Source menu to open the source code, could you help me to figure out why? Thanks a lot. Jenny Jenny wrote: > Hi, > > I can't use View, Source menu to open the source code of a page. I am > using WinXP and IE 6. Here is the link: Works fine in Firefox and IE. The charset is gb2312, which may require extra language support but I'm n...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal''''''''''''''
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; _____________________________________________________ SELECT "criteria" FROM "criteria" WHERE "criteria" UPDATE/APPEND "field selections" RecordSource "qryExample" = above text strings" _______________________________________________________________________ When i am running a SELECT query in this manner it works fine with no problems, and accepts the values of specified linked for...

Source code for 'top' or 'ps'
Hi, Anyone know where I might find the source code for either t"top" or "ps" as shipped with some distribution like redhat or suse or oter? Thanks, Jim -- --- Jim email: echo balsonAcomcastDnet | sed s/A/@/ | sed s/D/./ Jim Balson wrote: > Hi, Anyone know where I might find the source code for > either t"top" or "ps" as shipped with some distribution like > redhat or suse or oter? Assuming they are GPLed, you can get the sources from the distributor. You can find out which particular package they belong to by ...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal'''''''''''''' #2
Hi, Thanks for ur help there HJ. I know how to do the tasks you specified there. I would like for the update query to use field values from some of the fields on the form (frmInvoices) such as InvoiceNumber, DateFrom, DateTo. My problem is that an append/update query can't find the values in the open Form (frmInvoices) when I specify them as; [Forms]![frmInvoices]![InvoiceNumber] a select query has no problem finding the field values on a form. please help. Aaron Hi Aaron, Could you post the entire code that you are having trouble with? Now it is not possible to see what goes wrong. HJ "Aaron" <aaron@rapid-motion.co.uk> wrote in message news:260d7f40.0408120245.2f3d01f8@posting.google.com... > Hi, > > Thanks for ur help there HJ. > > I know how to do the tasks you specified there. > > I would like for the update query to use field values from some of the > fields on the form (frmInvoices) such as InvoiceNumber, DateFrom, > DateTo. My problem is that an append/update query can't find the > values in the open Form (frmInvoices) when I specify them as; > > [Forms]![frmInvoices]![InvoiceNumber] > > a select query has no problem finding the field values on a form. > > please help. > > Aaron First off, if you are not always using all the parameters specified in your form, then you have to add parameters to your query on the fly. Also, you can't just do something like qdf.SQL = "SE...

[News] [Rival] Windows Vista Source Code 'Leaked'
Windows Vista Source Code - Image http://i29.tinypic.com/10gidzr.jpg On Sun, 06 Apr 2008 15:44:20 +0100, Roy Schestowitz wrote: > Windows Vista Source Code - Image > > http://i29.tinypic.com/10gidzr.jpg Wow, you've just discovered a 13 year old joke, and in your typical narcissistic and self-absorbed fasion assume that because it's new to you, it must be new. Roy Schestowitz wrote: > Windows Vista Source Code - Image > > http://i29.tinypic.com/10gidzr.jpg That's about right... I just spent my Sunday morning trying to clear out a rogue Malware agent from ...

System76 has a sense of humor: uses 'open source' and 'world class' in the same sentence
"Through world class hardware, software and support, System76 enables consumers, businesses, schools, and governments to easily transition to the world of open source software." http://www.youtube.com/user/System76Video/featured?v=NFylMwry2h0 The music in the video sure sounds like open source: derivative crap On Wed, 22 Feb 2012 18:42:15 -0500, DFS wrote: > "Through world class hardware, software and support, System76 enables > consumers, businesses, schools, and governments to easily transition to > the world of open source software." > > http:/...

[News] 'Open Source' Hardware Runs Google's Open Source Linux Stack, Another Stack in the Making
GPhone Pics! Open-Source 'Bug' Can Run Android ,----[ Quote | ug Labs founder Peter Semmelhack just gave us a peek at his company's | prototype "open-source" mobile gadget, which should go on sale next month. | The "Bug" is essentially a Lego kit for geeks: A base unit can connect to | modules like LCD touchscreens (the one pictured to the right has two plugged | in), GPS, a digital camera, and forthcoming doodads like a 3G modem, etc. (If | you're into hardware engineering, you can also build your own modules.) `---- http://www.alleyinsider.com/...

Code works in Netscape 7.1 but not IE ---- document.getElementById('other').style.visibility='hidden';
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) { document.getElementById(nameOfDiv).style.visibility='visible'; document.getElementById(nameOfDiv).style.height='auto'; if (nameOfDiv != 'weblogs') document.getElementById('weblogs').style.visibility='hidden'; if (nameOfDiv != 'entries') document.getElementById('entries').style.visibility='hidden'; if (nameOfDiv != 'newsletters') docum...

[News] NSA Loves Open Source, Passes That 'Love' (Code) to OpenSolaris
High hopes for data storage ,----[ Quote ] | Exponential Storage hopes to one day persuade the National Security Agency | and other government bureaus to hire the company for its data storage | network. Its focus on NSA seems to have potential: The agency already | ^^^^^^^^^^^^^^^^^^ | established that open source software can be made secure and uses it for some | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | computer functions. | ^^^^^^^^^^^^^^^^^^ `---- http://www.baltimoresun.com/business/bal-bz.s...

[News] [OSS] Open Source an Advantage to Business and Open Source 'Fluff'
Open source more than hot air for gift etailer ,----[ Quote ] | "Where open source fits is in the areas of customization, as it | is totally customer-centric," Simpson said. "Open source has | worked powerfully for us because it is a community, it's so | user centric." `---- http://www.linuxworld.com.au/index.php?id=159023291&rid=-50 More fluffy use of the term: Mugshot: Social networking open source style ,----[ Quote ] | The Mugshot wiki provides precompiled binary packages for | Windows and several Linux distributions, including Fedora, | Ubuntu, Mandriva, ...

[News] Open Source 'Toaster' Runs Open Source O/S
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Unisa toasts open source success ,----[ Quote ] | It uses a customised open source operating system that allows the kiosks to | burn multiple disks at once. `---- http://www.itweb.co.za/sections/software/2008/0807181034.asp?O=FPTOP&S=Open%20Source&A=LIN Probably Linux-based, producing Linux CDs. Recent: Bridging the African digital divide - with a ‘toaster’ ,----[ Quote ] | The foundation was convincing schools and even government offices to switch | to Linux, the open-source equivalent of Microsoft Windows or Mac OS. | | “We were getting a lot of people excited about it,” Hudson says. But when new | fans asked how to get their hands on the newest version of Linux, the answer | was always the same: Download it. “We’d see their shoulders slump,” he | says. “We had a clear message, we were getting out there and talking to | people, but we were clearly falling short.” | | Then he started thinking – why not make a software vending machine where, | instead of having to download large files, a user could just burn them to a | CD? | | It so happened that the MTN Sciencentre in Cape Town was about to have an | exhibition on open-source computing, and Hudson convinced his bosses to let | him try to design a prototype that would burn a small selection of | open-source software, including Linux, to CDs. `---- http://features.csmonitor.com/innovation/2008/06/17/bridging-the-african-digital-divide-%E2%80%93-with-a-%E2%80%98t...

'Matlab Code' to 'Embedded Matlab fun code'
Dear friends, I have a Matlab code to process a pure analog signal 'u'. Now I want to implement it in Simulink and I want to use it in 'Embedded Matlab fun block' so i need to transform 'Matlab code' to 'Embedded Matlab fun code' to perform the task. The Matlab code is as follows: %%%%%%%%%%%%%%%%%%%%% u_abs = abs(u); major_th = 1.5e-1; minor_th = 1.8e-2; major_peak_value = []; minor_peak_value = []; pos = 1; pos_max = 1; while ~isempty(pos) [m pos_max(end+1)] = max( u_abs( pos : pos + 10) ); pos...

[News] Open Source Licence Evolves in Europe, 'Open-source' Car Released
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 European Commission approves update of EU public licence ,----[ Quote ] | The European Commission approved an update of the European Union Public | Licence (EUPL) on 9 January. Seven clarifications were made in the licence | text, not changing the original meaning. | | The Commission validated version 1.1 of the EUPL in all official languages of | the European Union. | | The text was changed slightly to clarify the licence, say sources involved in | the process. For example, regarding distribution and/or communication, | article 1 was c...

[News] [SOT] Lessig 'Open-sources' a Corrupt Progress; Open-source Cars
Exposing a closed Congress to Open Source: Change Congress ,----[ Quote ] | The first half of Lessig's remarks closely tracked the inaugural lecture on | corruption he delivered at Stanford last year, after announcing that he would | be abandoning the work on cyberlaw and free culture that had made him a geek | superstar in order to study the ways money's influence distorts the political | process. He detailed how, on an array of "easy questions" in areas ranging | from copyright terms to dietary recommendations to climate change to military | procurement, the interests of funders had driven a wedge between policy | formation or academic inquiry and the overwhelming consensus of impartial | experts. He also offered conservatives, who have often been skeptics of | campaign finance reform, a rationale to share his concerns: "Why is | government so big?" Lessig asked rhetorically. "Because congressmen must get | elected." He claimed, for example, that legislators had been reluctant to | establish a more deregulated telecommunications framework for the Internet in | the 1990s because the looming threat of regulation kept campaign | contributions rolling in from telecom firms. `---- http://arstechnica.com/news.ars/post/20080323-exposing-a-closed-congress-to-open-source-change-congress.html The Amazing Race ,----[ Quote ] | David Warren, 30, works as an engineering product manager for a defense | contractor by ...

[News] Google Maps: Open API's, Open Data, and Open Source Code
Open-source project treads on Google Maps turf ,----[ Quote ] | Volunteer "citizen cartographers" are aiming to take on the | likes of Google Maps and Britain's Ordnance Survey by creating | a free, open-source wiki-style map of the planet. `---- http://news.zdnet.com/2100-9588_22-6134871.html begin oe_protect.scr Roy Schestowitz <newsgroups@schestowitz.com> espoused: > Open-source project treads on Google Maps turf > > ,----[ Quote ] >| Volunteer "citizen cartographers" are aiming to take on the >| likes of Google Maps and Britain's Ordna...

Fast code to replace 'find' (& 'interp1')
Hi, I have written an interpolation routine as a function that is faster than the inbuilt function 'interp1'. However, its not fast enough and the 'find' function takes 80% of the computation time. I need a piece of code that does the same job as 'find' but megga fast (can't access source code to make my own, 'stripped out' version) Can anybody help? Thank you Andy "andrew newton" <a.p.newton@lboro.ac.uk> wrote in message news:eece88d.-1@webx.raydaftYaTP... > Hi, > > I have written an interpolation routine as a f...

Using \width, \height and \totalwidth for 'width', 'height' and 'totalheight' arguments of \includegraphics (Code provided)
Hello, with the 'graphicx' package the width and height of an image can be given using the 'width' and 'height' (as well as \totalheight) option of the \includegraphics. However, there seems to be no (easy) way to allow both height and width to be set relative to its original value, e.g. scale the width by 2 and the height by 3, etc. It would be nice to be allowed to use the usual box related dimensions \width, \height and \totalheight as values for the options with the same name. Together with the 'calc' package or e-TeX's \dimexpr some arithm...

'from lon-lat to TM' source code?
Hi, everyone! I would like to change the longetude, latitude info into TM (Transverse Mercatore). I tried to make one, but I am still beginner of IDL, and I also thought it is possible someone has already maden. Is there anyone who has this source code 'from (lon,lat) into TM'? Thanks. DirtyHarry wrote: > Hi, everyone! I would like to change the longetude, latitude info into > TM (Transverse Mercatore). I tried to make one, but I am still beginner > of IDL, and I also thought it is possible someone has already maden. Is > there anyone who has this source code 'from (...

Using the 'OpenAs' dialog
Hello All, For a small app I'm creating I would want to use the 'Open with' dialog for my own purposes. The function I'm using is ShellExecuteEx function, which utilizes the SHELLEXECUTEINFO structure. The arguments I'm using are the verb "openas" together with the SEE_MASK_INVOKEIDLIST flag. http://msdn.microsoft.com/en-us/library/windows/desktop/bb759784(v=vs.85).as px My questions: 1) I assume that the 'always open with' tickmark causes alterations in the registry. In that case, can I (easily) disable it ? 2) Can I determine which app...

Like '' & '' & ''
Having this description column in a table "Cookies, peanut butter sandwich, regular" When using this WHERE clause: WHERE (((Food_Data.Description) Like "*Butter*" & "*Peanut*")); I dont get any results, however when using it this way round WHERE (((Food_Data.Description) Like "*Peanut*" & "*Butter*")); I get the row as expected. I assume that the query looks for them in order. Is there a way i can get around this and make the query search for both keywords no matter which order i ype them in. Thanks Dave [posted and mail...

'&' or '&&' ??
In an if statement which operator & or && is best to used for and? In article <fmgr8a$a5s$1@news.net.uni-c.dk>, saneman <yyyy@dd.com> wrote: >In an if statement which operator & or && is best to used for and? && if you are working with scalar values, and & if you are working with a vector. -- "I will speculate that [...] applications [...] could actually see a performance boost for most users by going dual-core [...] because it is running the adware and spyware that [...] are otherwise slowing down the single CPU that user has...

Fast code to replace 'find' (& 'interp1') #2
Hi, I have written an interpolation routine as a function that is faster than the inbuilt function 'interp1'. However, its not fast enough and the 'find' function takes 80% of the computation time. I need a piece of code that does the same job as 'find' but megga fast (can't access source code to make my own, 'stripped out' version) Can anybody help? Thank you Andy andrew newton wrote: > > > Hi, > > I have written an interpolation routine as a function that is > faster > than the inbuilt function 'interp1'. H...

[News] Microsoft's New Scheme: If The World Wants Open Source, We'll Pretend to Be Open Source And Corrupt the Term
More attempts to corrupt the term. Now that the EC wants Open Source, Microsoft will try to confuse everyone. The Novell deal was only the start. Fake. Fake. Fake. Fraud. Corruption. Marketing Ploy. Microsoft and Open Source: The Real Deal? ,----[ Quote ] | Sure looks like it, based on the company's partnership with Novell. `---- http://redmondmag.com/reports/article.asp?EditorialsID=416 Why Microsoft should open-source SQL Server and SharePoint ,----[ Quote ] | This time, the former Softie is making a case for why Microsoft | should consider open-sourcing some of its crown jewels, includingS | QL Server and SharePoint. `---- http://blogs.zdnet.com/microsoft/?p=206 Aras Ushering in 'Microsoft Enterprise Open Source' ,----[ Quote ] | Aras Innovator 8 requires Microsoft Windows Server 2003 with .NET | 2.0 and Microsoft SQL Server 2005. The software is freely available | from the Aras website. The software's CodePlex project page is | located here. `---- http://www.enterpriseitplanet.com/networking/news/article.php/3654756 Previously: Using open source as a marketing ploy ,----[ Quote ] | This is typical trend riding fluff. If you go the Aras website you | read about "Microsoft Enterprise Open Source Solutions", which is | comical in and of itself. `---- http://weblog.infoworld.com/openresource/archives/2007/01/more_open_sourc.html Soft sell for open source apps ,----[ Quote ] | When vendors aren't counting licenses, they're f...

[News] Microsoft 'Insider' Spotted in OpenLogics's 'Open Source' Monitoring Project
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Microsoft Joins Open Source Usage Spying Program ,----[ Quote ] | From OpenLogic's (the parent company of the OSC) team website: | | Steven L. Grandchamp, CEO . . . | | Steven also held various senior management positions with Microsoft including | the application development segment of Microsoft Consulting Services. Steven | spent the early part of his career in progressively responsible IT roles in | the banking industry. `---- http://technocrat.net/d/2008/6/17/43756 Yesterday: Conspiracy theory: Microsoft sponsors open source ...

Web resources about - No content (source code) while using 'window.open' in Mozilla, Opera, Chrome & Safari (source code only visible in IE) - comp.lang.javascript

Resources last updated: 3/12/2016 4:14:45 AM