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!

cf location and javascript onLoad

Status
Not open for further replies.

bluetang

Technical User
Apr 10, 2001
14
DE
Hi,

Firstly I apologise for putting a coldfusion related question in here, but it is javascript related too and I have already tried the coldfusion forum.

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:



<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
 
<head>
<script language=&quot;javascript&quot;>
function doit() {
window.print()
history.back()
}
</script>
</head>

<body onload=&quot;doit()&quot;>

Get rid of the CF tag that send the user back Use the function above and it shows the window print box, then after that box is closed, the browser goes back to the originating page.
 
Hi,

You can use this:

<body onLoad=&quot;javascript:window.print();document.location.href='somePage.cfm'&quot;>

Like this, you wont need the cflocation.

Gtz,

Kristof
 
Thanks guys 'n' gals,

Kristof's code seems to be working ok so now I just need to figure out how to get the variables back to the original page, but as that's a cf thing I'll be off back over there now :)

Thanks again
Sara
 
actually as this post is a cross post, i answered in the cf forum !!
the point here was that cf is SERVER side, so <cflocation ...> was executed before the page could be loaded - so the javascript was not even executed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top