Skip to main content
July 21, 2016
Answered

Unable to open a coldfusion file using window.open() javascript function

  • July 21, 2016
  • 4 replies
  • 2428 views

This is my code :

window.open("myPage.cfm?froma=1&p_varA=#varA#&p_varB="+varB+"", "_new", "menubar=no, location=no, status=yes, toolbar=no, width=700px, height=800px, scrollbars=yes, resizable=yes, left=50, top=100")

This does not open up the pop-up in some of the user's IE 11 browsers. It works on my IE 11 browser. What could be the blocking factor.

The same code breaks in Mozilla Firefox with JavaScript error.

Please give your valuable suggestions.

    This topic has been closed for replies.
    Correct answer WolfShade

    If the error is a JavaScript error, then the browser console (F12) will tell you what that error is.  If you're testing in FireFox, I highly recommend FireBug as a troubleshooting tool.

    I'm going to assume that you've placed the JavaScript in between CFOUTPUT tags. 

    If it works in some IE11 browsers, but not in all, then the likely culprit would be individual user settings (including but not limited to "Compatibility View"), browser security settings, or network security settings.

    Find the error message and post it, here.  We'll see what we can discover. 

    HTH,

    ^_^

    UPDATE:  According to Mozilla Developer Network, you don't use "px" as part of the value for height or width.

    UPDATE2:  Another thing I didn't think of, until now: pop-up blockers.  If any IE11 isn't opening the pop-up, is the user using a pop-up blocker?

    4 replies

    July 25, 2016

    Hi Eddie

    The code you provided works on my machine on both IE and Firefox.

    The syntax  ---> &p_varB="+varB+" also works. I am waiting for response from the User.

    Thanks for your response!

    EddieLotter
    Inspiring
    July 21, 2016

    A working example.

    Contents of MyPage1.cfm:

    <!doctype html>

    <html lang="en">

    <head>

      <meta charset="utf-8">

    </head>

    <body>

      <cfset varA = "a">

      <cfset varB = "b">

      <script type="text/javascript">

        <cfoutput>

          window.open("myPage2.cfm?froma=1&p_varA=#varA#&p_varB=#varB#", "_new", "menubar=no, location=no, status=yes, toolbar=no, width=700, height=800, scrollbars=yes, resizable=yes, left=50, top=100");

          //var varB = 'example';

          //window.open("myPage2.cfm?froma=1&p_varA=#varA#&p_varB="+varB, "_new", "menubar=no, location=no, status=yes, toolbar=no, width=700, height=800, scrollbars=yes, resizable=yes, left=50, top=100");

        </cfoutput>

      </script>

    </body>

    </html>

    You can uncomment the two commented lines to use the javascript variable.

    Contents of myPage2.cfm:

    <!doctype html>

    <html lang="en">

    <head>

      <meta charset="utf-8">

    </head>

    <body>

      <cfdump var="#url#" >

    </body>

    </html>

    Cheers

    Eddie

    WolfShade
    WolfShadeCorrect answer
    Legend
    July 21, 2016

    If the error is a JavaScript error, then the browser console (F12) will tell you what that error is.  If you're testing in FireFox, I highly recommend FireBug as a troubleshooting tool.

    I'm going to assume that you've placed the JavaScript in between CFOUTPUT tags. 

    If it works in some IE11 browsers, but not in all, then the likely culprit would be individual user settings (including but not limited to "Compatibility View"), browser security settings, or network security settings.

    Find the error message and post it, here.  We'll see what we can discover. 

    HTH,

    ^_^

    UPDATE:  According to Mozilla Developer Network, you don't use "px" as part of the value for height or width.

    UPDATE2:  Another thing I didn't think of, until now: pop-up blockers.  If any IE11 isn't opening the pop-up, is the user using a pop-up blocker?

    July 21, 2016

    Hi Wolf Shade

    Thanks for the feedback!

    The IE Web Console does not show any error.

    This is not a Pop Up Blocker Issue. What are the browser settings that can stop this from working ?

    WolfShade
    Legend
    July 22, 2016

    anithav86922272 wrote:

    The IE Web Console does not show any error.

    Hmm.. but FireFox does indicate a JavaScript error?  Install FireBug on your FireFox (if you don't already have it) and use that for tracking the JavaScript issue.

    Honestly, I code for FireFox, first, then make corrections for IE, later.

    HTH,

    ^_^

    UPDATE: Oh, and if you could, please, post your corrected code for review.  Tnx!

    EddieLotter
    Inspiring
    July 21, 2016

    It would be helpful if you posted the complete error messages you get so that we can help you.

    I do see an immediate problem:

    p_varB="+varB+""

    should be

    p_varB=#varB#"

    Cheers

    Eddie

    WolfShade
    Legend
    July 21, 2016

    I'm going on an assumption, but I believe the second variable is a JavaScript variable, not a CF variable.

    V/r,

    ^_^

    EddieLotter
    Inspiring
    July 21, 2016

    That's a reasonable guess, which would mean the OP needs to change it to:

    p_varB="+varB

    Cheers

    Eddie