Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cflocation and javascript onLoad

Status
Not open for further replies.

bluetang

Technical User
Apr 10, 2001
14
DE
Hi,

Firstly I apologise for putting a javascript related question in here, but it is cf related too and I didn't know where to ask first.

I am trying to figure out how to get my page to print when it loads and then return to the page it was linked from without the user having to click on any back links.

The code I have at the moment is:

Code:
<body onLoad=&quot;javascript:window.print();&quot;>

              blah, blah, blah

<cflocation url=&quot;originalpage.cfm&quot; addtoken=&quot;No&quot;>

</body>

This is going back to the original page ok, but is not offering the browser print menu on it's way through.

How can I get the javascript to work before the cflocation tag whisks the user back to the other page?

Many thanks in anticipation
Sara
 
this behaviour is normal : cflocation redirects BEFORE the javascript is executed - the page is NOT even loaded
use set time out - perform a search on the javascript forum or even in the javascript's faq i'm sure you'll get an answer pretty quickly

 
Hi,

Thanks ever so much iza, I'll try there now :)

Sara
 
sorry, i wrote something really dumb
i told you the javascript couldn't get executed and then to use a javascript function !!!
so
* either use pure javascript, as you were told in the javascript forum - window.print, then the time out, finally the document.location
* or (but i don't remember if this exists ...) use a cf tag to time out, and then cflocation ...
hope you'll manage to make it work !
let us know (here or in the javascript forum)
 
Hi iza,

Thanks very much for your help. I used the following javascript:

Code:
<body onLoad=&quot;javascript:window.print();document.location.href='makertpline.cfm?RTP_no=#rtp#'&quot;>

and removed the cflocation tag altogether.

This means that now I can click on a button in one page to print another page without the user seeing more than a fleeting glimpse of it :-D

Excellent, thanks very much.

Sara
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top