0
Running Javascript Code to Close Window at end of page

/t5/coldfusion-discussions/running-javascript-code-to-close-window-at-end-of-page/td-p/84125
Aug 28, 2008
Aug 28, 2008
Copy link to clipboard
Copied
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>
My close window link code is as follows:
<a href="javascript:;" onclick="opener.location='https://somewebsiteurl.com/#form.somevar#';self.close();">Close Window</a>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Valorous Hero
,
/t5/coldfusion-discussions/running-javascript-code-to-close-window-at-end-of-page/m-p/84126#M8375
Aug 28, 2008
Aug 28, 2008
Copy link to clipboard
Copied
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();
// refresh parent window
window.opener.location.refresh();
self.close();
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/coldfusion-discussions/running-javascript-code-to-close-window-at-end-of-page/m-p/84127#M8376
Aug 29, 2008
Aug 29, 2008
Copy link to clipboard
Copied
That worked! I was worried that the coldfusion code would not
run first, but it did.
Thanks!
Thanks!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Valorous Hero
,
/t5/coldfusion-discussions/running-javascript-code-to-close-window-at-end-of-page/m-p/84128#M8377
Aug 29, 2008
Aug 29, 2008
Copy link to clipboard
Copied
Yes, ColdFusion code always executes first. Because CF code
runs on the server, whereas javascript runs in the client
browser.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/running-javascript-code-to-close-window-at-end-of-page/m-p/84129#M8378
Aug 29, 2008
Aug 29, 2008
Copy link to clipboard
Copied
Art of Zen wrote:
> 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*
Art of Zen wrote:
> 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.
> 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*
Art of Zen wrote:
> 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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Valorous Hero
,
LATEST
/t5/coldfusion-discussions/running-javascript-code-to-close-window-at-end-of-page/m-p/84130#M8379
Aug 29, 2008
Aug 29, 2008
Copy link to clipboard
Copied
Ian Skinner wrote:
> 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 ;-)
> 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 ;-)
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

