Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 26th, 2005, 09:11 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default print page that is not the current page

I got a problem with javascript, that i want to print out hyperlink's contents of the webpage, which without open the webpage. Now, i had writen some codes, which intend to do this task.
But i had meet a problem....so can anyone give me a hand?
This code works:
<title>printing a remote document</title>
function printURL(sHref) {
  if(document.getElementById && document.all && sHref){
      var aHeads = document.getElementsByTagName('HEAD');
      if(!aHeads || !aHeads.length)
        return false;
        self.oPrintElm = document.createElement('LINK');
      self.oPrintElm.rel = 'alternate';
      self.oPrintElm.media = 'print';
    self.oPrintElm.href = sHref;
    return true;
  else return false;
<h2>The following article discusses what DHTML is, and also the differences in implementation of DHTML between Netscape Communicator and MS Internet Explorer 4. </h2>
<p>What is DHTML? <br>
  DHTML(Dynamic HTML) is a technology supported by Netscape Communicator and IE 4 that enables a web document to be dynamic. DHTML is NOT JavaScript, but rather, a generic enhancement to the browser itself that allows elements to be moved around, content to appear and disappear, text to change even after the document has loaded etc. JavaScript (or any other scripting language, for that matter), merely provides the means to access these enhancements. DHTML is not a programming language, but a feature. </p>
<p>What's the difference between DHTML in Communicator, and in Internet Explorer 4.0? <br>
  Everything. Communicator and Internet Explorer 4 are currently at very different stages in terms of support for DHTML as recommended by WC3. In short, Communicator is considered vastly behind in its support for true DHTML, while IE 4 is more on track. Its important to realize that both browsers do not yet completely support the DHTML technology as outlined by the WC3. Below lists how Dynamic HTML is implemented in the two browsers: </p>
<p>In Communicator:
<a target="_blank" href="http://www.saltstorm.net/" onclick="printURL(this.href); return false;">print http://www.saltstorm.net</a>
But when i try to change it to my local file, this code doesnt:

it just prints the page it is on.

function printURL(sHref)
  if(document.getElementById && document.all && sHref)
      var aHeads = document.getElementsByTagName('HEAD');
      if(!aHeads || !aHeads.length)
        return false;
        self.oPrintElm = document.createElement('LINK');
      self.oPrintElm.rel = 'alternate';
      self.oPrintElm.media = 'print';
    self.oPrintElm.href = sHref;
    return true;
  else return false;

<td width="21%" align="center" bgcolor="#006699" onMouseOver="this.bgColor = '#C0C0C0'; this.style.color='#000000'; style.cursor='hand'" 
onMouseOut="this.bgColor = '#006699'; this.style.color='#FFFFFF'">

<a target="_blank" href="printBooking.asp?pnrno=<%=pnrno%>"
onclick="printURL(this.href); return false;" style="color:#FFFFFF "
onMouseOver="this.style.color='#000000'" onMouseOut="this.style.color='#ffffff'">View and Print Booking</a>

Ayrshire Minis - a Mini E-Community
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Print a page without changing page setup nrajeshatwork Servlets 1 May 23rd, 2007 10:09 AM
Emailing current page toma12 ASP.NET 2.0 Professional 1 November 29th, 2006 12:31 PM
Redirect to new page without closing current page peter2004 ASP.NET 2.0 Basics 5 June 5th, 2006 08:49 PM
print the hidden page without the print dialog box kayzem Classic ASP Basics 0 April 21st, 2005 11:31 PM
reference of prev. page in current page kasanar ASP.NET 1.0 and 1.1 Professional 1 February 13th, 2005 02:49 PM

All times are GMT -4. The time now is 02:28 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.