• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Jul 21, 2016 Jul 21, 2016

Copy link to clipboard

Copied

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.

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 21, 2016 Jul 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 m

...

Votes

Translate

Translate
Advocate ,
Jul 21, 2016 Jul 21, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 21, 2016 Jul 21, 2016

Copy link to clipboard

Copied

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

V/r,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 21, 2016 Jul 21, 2016

Copy link to clipboard

Copied

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

p_varB="+varB

Cheers

Eddie

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 21, 2016 Jul 21, 2016

Copy link to clipboard

Copied

Yes varB is a JavaScript variable

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 21, 2016 Jul 21, 2016

Copy link to clipboard

Copied

Did you correct the syntax error I pointed out?

Cheers

Eddie

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 21, 2016 Jul 21, 2016

Copy link to clipboard

Copied

Hi Eddie

It works on my IE browser with the above syntax mentioned in the question. Fails in the users machine . They also use IE11.0.96

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 21, 2016 Jul 21, 2016

Copy link to clipboard

Copied

Do the test scripts I provided you also fail on your user's machine?

Cheers

Eddie

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 21, 2016 Jul 21, 2016

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 21, 2016 Jul 21, 2016

Copy link to clipboard

Copied

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 ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 22, 2016 Jul 22, 2016

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 25, 2016 Jul 25, 2016

Copy link to clipboard

Copied

anithav86922272​, do the test scripts I provided you also fail on your user's machine?

Cheers

Eddie

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 26, 2016 Jul 26, 2016

Copy link to clipboard

Copied

Page1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head> 

<title>MyPage</title>  

</head> 

<body> 

  <cfset varA = "a"> 

  <cfoutput> 

     <SCRIPT LANGUAGE="JavaScript"> 

            function doCreate()

      {

     var varB=1;

     if (varB==1)

      {var r = window.open("myPage2.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");

      return true}

         }

   </SCRIPT>  

   </cfoutput>   

    

  

     <FORM>

  <INPUT TYPE="button" NAME="create" ID="create" VALUE="CREATE" STYLE="width:275px" onClick="return doCreate()">

     </FORM> 

  

</body> 

</html>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 26, 2016 Jul 26, 2016

Copy link to clipboard

Copied

Page 2

--------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html> 

<head>

<title>Pop-Up</title>

</head> 

<body> 

<cfdump var="#url#"> 

</body> 

</html>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 26, 2016 Jul 26, 2016

Copy link to clipboard

Copied

This is how the corrected code looks. The pop up window does not appear for two of the users but works for others and myself. We are using IE 11 browser.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 26, 2016 Jul 26, 2016

Copy link to clipboard

Copied

A) You can take out the "return true", it's not needed.

B) Height and width cannot use "px" as part of the value; these should be integers only.

Your code looks solid, otherwise.  Are you sure that the pop-up flat-out isn't opening?  Is there a chance that it's opening, but behind the parent browser?  You could set the focus after the pop-up:  r.focus(); in place of return true;

HTH,

^_^

UPDATE:  Change your doctype declaration to:

<!DOCTYPE html>

The one you are currently using is way out of date.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 26, 2016 Jul 26, 2016

Copy link to clipboard

Copied

LATEST

It sounds like JavaScript is disabled on the problem users' computers.

Change the following line

<INPUT TYPE="button" NAME="create" ID="create" VALUE="CREATE" STYLE="width:275px" onClick="return doCreate()">

to

<INPUT TYPE="button" NAME="create" ID="create" VALUE="CREATE" STYLE="width:275px" onClick="alert('JavaScript is enabled.')">

and ask your problem users to test it.

Cheers

Eddie

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 21, 2016 Jul 21, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 25, 2016 Jul 25, 2016

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation