Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / General CF Topics / August 2008



Tip: Looking for answers? Try searching our database.

Running Javascript Code to Close Window at end of  page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Art of Zen - 29 Aug 2008 01:30 GMT
I have a popup window form that submits data and then upon clicking a link,
closes itself and refreshes the parent page.  Is there a way to do this after
automatically without having to click the link?  By that I mean, is there a
coldfusion tag that allows for the javascript to run at a certain point in my
lines of code (on the cf page my form posts to)?

My close window link code is as follows:

<a href="javascript:;"
onclick="opener.location='https://somewebsiteurl.com/#form.somevar#';self.close(
);">Close Window</a>
-==cfSearching==- - 29 Aug 2008 01:54 GMT
With a basic window, that is a javascript task. Add some javascript to your
submission page and call it on page load.  I do not remember the correct syntax
offhand, but something like:

// refresh parent window
window.opener.location.refresh();
self.close();
Art of Zen - 29 Aug 2008 19:20 GMT
That worked!  I was worried that the coldfusion code would not run first, but it did.

Thanks!
Ian Skinner - 29 Aug 2008 20:00 GMT
> By that I mean, is there a coldfusion tag that allows for the javascript to run at a certain point in my
> lines of code (on the cf page my form posts to)?

*AND*

> That worked!  I was worried that the coldfusion code would not run
> first, but it did.

I just wanted to bring up the concept here the indicates a fundamental
and very common beginning misconception.

The distinction between ColdFusion and JavaScript and how they *do* and
*do not* relate to each other.

The former only runs on a server and will never run at the same time as
the latter which only runs on a client.  You can never have ColdFusion
code and JavaScript code 'interact' with each other in a procedural manner.

There are very powerful techniques to use ColdFusion to build dynamic
JavaScript to be sent to and run on the client.  There are DHTML|AJAX
methods to have JavaScript make new requests to a server and have
ColdFusion generate and then send new content to the client behind the
scenes.  But they do not work 'together', i.e. each one has no clue what
the other knows or is doing.

I have repeatedly witnessed the frustration and difficult new web
programmers have until they grok the deferences between the server code
and the client code and how the twain will never meet.
-==cfSearching==- - 29 Aug 2008 20:44 GMT
> I have repeatedly witnessed the frustration and difficult new web
> programmers have until they grok the deferences between the server code
> and the client code and how the twain will never meet.

Yes, Ian raises a very important point.  I was going to post a follow up about
this, and was searching for a great link over at houseoffusion.com that
outlines the relationships and differences.  (I am too lazy to type today).
Fortunately, Ian saved me the trouble ;-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.