We help IT Professionals succeed at work.

Cold Fusion and opening a new sized window

greeneye8
greeneye8 asked
on
Medium Priority
312 Views
Last Modified: 2013-12-24
I am trying to use Cold Fusion to open up a 'new window" within my Cold Fusion application.  I have several Java scripts I have used for HTML sites to open up new windows, but the scripts do not seem to work for calling up a new window to a certain size within my cold fusion application.  I do undertand that CF is a sever side application unlike Java with runs on the client side.

Is there a CF tag to achieve this  possibly? If so, how?

Currently, in my head tag I am using this:

<script>

function schools(){
schoolsWindow = window.open ("http://www.mydomain.com/schools.cfm?page=1021","books","scrollbars=yes,width=591,height=528");
}
</script>

then in my text, I have this:

To view the schools click <a href="javascript:schools()">here:</a>

However, CF will not open up  schools.cfm?page=1021 because it is a dynamic page.

Is there a special CF tag that will allow me to open up a new "sized" window to a dyamic page within my website?

Thanks




Comment
Watch Question

think you are missing a ;

<a href="javascript:schools();">here:</a>

Author

Commented:
The semi does not enable the script to work.  The script works fine and I have been using it for years with html pop ups with the semi:

a href="javascript:schools()">here:</a>

The problem with Jave is that I don't think it can pass Cold Fusion variables through it.  So my question is, can Cold Fusion even do this.... open up a controlled window (size, scrolling, etc.) within a Cold Fusion application?

Here is an example of what I am trying to do:  If you visit:

http://icarealty.com/index.cfm

This is a CF site.  If you scroll down to the very bottom, I have a link on the right hand side called 'test'.  Currently that is linking over to another dynamic page on the site.  What I am trying to figure out is how can I make my 'test' link  or another link on that site open up a "new window" that I can control the size and other attributes of the window.  

Thanks
First of all, forcing a popup window on a user is an unfortunate UI decision.  That being said, the least you could do is make it so JavaScript isn't required to access the contents of the link.

http://jeffhowden.com/articles/links_and_javascript/

Second, JavaScript doesn't care what server-side language a particular link calls just as much as your server-side language of choice cares that it was requested by a browser (in a popup or not), HTTP analysis tool, a server process, etc.

Perhaps you could help the experts assisting with your question by giving a more accurate description of the problem than simply saying "CF will not open up ... because it is a dynamic page".  Are you getting a JavaScript error when clicking on the link?  Does the popup open?  If it opens, what are you seeing in the popup window?  Is it not the page you expected?  Does it result in a ColdFusion error?  Have you tried opening the link in a regular window?  Do you get the same or different results than when attempting to open it in the popup?
Commented:
In the html head part of your page add the following;

<script type="text/javascript">
<!--    
function newWin(theURL,winName,features) {
    window.open(theURL,winName,features);
}

//-->
</script>

Then for your link,
<a href="JavaScript:parent.newWin('factsheet.cfm?pi=100415','cf','width=400,height=230,scrollbars=no');">Test</a>

Of course replacing the width, height, and actual link with whatever you are aiming for. I just threw in factsheet.cfm with the pi of whatever was there when I clicked.

The javascript works with any webpage, assuming your user has javascript enabled. If they don't, there's not really a way to force a pop-up. There isn't anything specific to ColdFusion that does this function, and if there were, it would just be something to generate javascript similar to what I've posted. Hope that helps.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
For more information on window.open and what features you could pass,
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp
"The javascript works with any webpage, assuming your user has javascript enabled. If they don't, there's not really a way to force a pop-up."

This is not a completely true statement.  Teggert, you got him started off right by suggesting the use of a function instead of calling the window.open() method inline.  However, first, the "parent.newWin()" call is going to throw the OP for a loop.  Second, you're needlessly crippling the link for non-JS users.  Try something more like this instead:

<a href="factsheet.cfm?pi=100415" target="_blank" onclick="newWin(this.href, this.target, 'width=400,height=230,scrollbars=no'); return false">Test</a>

Non-JS users will get a new window.  JS users will get a popup.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.