Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     javascript - run fex in new window
Page 1 2 

Read-Only Read-Only Topic
Go
Search
Notify
Tools
javascript - run fex in new window
 Login/Join
 
Platinum Member
posted
Hi All,

I am calling a fex from within another via an javascript call. The new report runs/opens but does so within the existing browser window. I would like it to be a popup window but cannot determine what I am doing wrong.

The window call is contained within a function and looks like this: window.open(myUrl,'mywindow','width=200,height=200');

The function is called from a link that looks like this:

Show Text Data



Does anyone have any ideas on what I am hosing up here?

I'm digging this javascript and page construction because of the control that you can have over functionality, output format etc. But there must be some nuances about WebFocus javascript that I need to understand.

Thanks,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Expert
posted Hide Post
Norb,

JavaScript is JavaScript and is not flavoured by WebFOCUS at all, so you have your pick of all the syntax you want.

Check out this site for a handy reference location - w3schools

<html>
<head>
<title></title>
</head>
<body>
<a href="javascript:openit();">Click me</a>
<script language=javascript>
function openit() {
myWindow = window.open('http://www.w3schools.com/js/','mywindow','width=200,height=200');
}
</script></body>
</html>

T

This message has been edited. Last edited by: Tony A,



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
in the second fex you are calling, in the TYPE=REPORT section of the stylesheet, try adding TARGET=_new,

Should open that report in a new window


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Platinum Member
posted Hide Post
Thanks for your reply Darin.

I'm sure your solution would work if I were using the WebFocus stylesheet - but I'm not. I'm creating and calling the link from the internal javascript in the -HTMLFORM section.

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Virtuoso
posted Hide Post
Somewhere in there you're creating a link (containing a Call - CGI or servlet) to execute another fex, SAMPLE.FEX.
Within SAMPLE.FEX, add the TARGET=_new. Whenever SAMPLE.FEX is run (regardless of whether it's run from and HTMLFORM, hyperlink, drilldown, etc.), it is forced to open itself in a new window.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Platinum Member
posted Hide Post
Well...

As per Darin's post: I tried adding a "TARGET=_new" to the url that calls the servlet and it does not open in a new window.

And as per Tony's post: the link to www.w3schools.com/js/ did indeed open but not in a new browser window. It just opened in the existing window.

I did a micro-test with the car file and it opens in a new window. Bummer! It must be something squirrely that I'm doing in the rest of the fex somewhere. The fex is huge. Looks like a new window is not in the cards. Boo Hoo!

Thanks everyone.

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Virtuoso
posted Hide Post
Norb,

How are you calling the JAvaScript that is supposed to open the new window? Do you have JAVASRIPT= in the focexec style sheet?


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Virtuoso
posted Hide Post
quote:
Within SAMPLE.FEX, add the TARGET=_new.


NOT in the URL, put it in the new fex


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Platinum Member
posted Hide Post
Hi Mickey!

I am calling the javascript as shown below:

-HTMLFORM BEGIN
<head>
<title>OTC - Salesperson Trends</title>

<script type="text/javascript">

function runFex() {

  var myUrl = "http://webfocus.scherer.com/ibi_apps/WFServlet?IBIAPP_app=otc&|IBIF_ex=trendtxt01&|USERID=&USERID&|LOC=&LOC&|ECODE=&ECODE&|HDRTXT1=&HDRTXT1";
  window.open(myUrl,'mywindow','width=400,height=600');
}
</script>

<style>
p
{
  font-family: Arial;
  font-size: 9;
  padding-left: 20px;
  line-spacing: 1;
}
.title {
  font-family: Arial;
  font-size: 12;
  font-weight: bold;
  padding-left: 20px;
  color: #5A88AC;
}
div.float {
  float: left;
  }
</style>
</head>

<body>
<p class="title">&HDRTXT1</p>
<div>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
  <td> !IBI.FIL.GRSMAN1; <hr> </td>
</tr>
<tr>
  <td> !IBI.FIL.GRSMAN2; </td>
</tr>
</table>
</div>
<p><a href="javascript:runFex();">Show Text Data</a></p>
<p></p>
<p></p>
<p></p>
<p>&NOW <br> &DD0 </p>
</body>
-HTMLFORM

-GAMEOVER
END


I put everything that resides in the HTMLFORM block for your perusal. Let me know if you see anything boneheaded.

By the way, are you gonna be at Summit again? One of my co-workers is going to present there so I'll have to heckle her. Maybe you'd care to join me in handing out verbal abuse. ;-)

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Platinum Member
posted Hide Post
Hi Darin,

I tried the TARGET=_new and it does not work for me. Bummer.

Here is the code:

TABLE FILE OTCEXPGR
SUM
&SELECT AS 'Count'
BY TOTAL HIGHEST &SELECT NOPRINT
BY SMAN2 AS 'Sales Support'
&W_CODE
&W1_CODE
ON TABLE COLUMN-TOTAL
ON TABLE SET PAGE-NUM OFF
ON TABLE HOLD AS SMAN2TXT FORMAT HTMTABLE
ON TABLE SET STYLE *
TYPE=REPORT, TARGET=_new, $
ENDSTYLE
END
-RUN

and then I've got the HTMLFORM code to display the table. Actually I'm displaying two tables but I only showed one here.

Thanks,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Virtuoso
posted Hide Post
Norb,

I created an HTML file using the code you included and it works fine for me. It pops up a new window for the url specified in the function. Try running it in Firefox and IE to see if you experience the issue in both browsers. It works for both browsers for me.

Is you browser blocking pop-ups?


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Platinum Member
posted Hide Post
Mickey,

I disabled the popup blocker in IE although it had been configured to allow popups for the domain that webfocus runs from. Ran the code and still the window will not open as a popup. I also got the same results in FireFox.

This is a complex fex (in my opinion) so I'm not real excited about commenting out code to try and simplify this thing until it works correctly or I have no code left.

Thanks,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Virtuoso
posted Hide Post
Norb,

If I understand correctly, the link to call the JavaScript function is not related to the report output in any way. Could there be a duplicate function name?

The only other thing I can think of is to dig through the security settings of your browser or talk to a PC administrator to see why a new window is not being openned.


FYI: I will be at the next Summit and I will also be presenting.


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Virtuoso
posted Hide Post
Norb,

One more thing to try. Add the beginning and ending HTML tags to your code.

-HTMLFORM BEGIN
<html>
.
.
.
</html>
-HTMLFORM END


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Platinum Member
posted Hide Post
Mickey,

Nope - no duplicate function names. The only connection between the javascript function and the fex it resides in are the amper variables that are embedded in the url within the function.

I'm so frustrated with this that I am going to dissect the code bit by bit until it works or is completely obliterated.

I'll have to check out your Summit presentation - assuming no schedule conflicts.

Thanks for your help,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Virtuoso
posted Hide Post
Well I'm with Mickey on this. The code you posted at 3:08 is fine except for the slight issues that Mickey has pointed out. For me it opened a new window in IE and Firefox.

The javascript you have is totally straightforward and is used in millions of apps worldwide.

So what you need to do is to do a view source of the html page and check that the line
var myUrl = "http://webfocus.scherer.com/ibi_apps/WFServlet?IBIAPP_app=otc&|IBIF_ex=trendtxt01&|USERID=&USERID&|LOC=&LOC&|ECODE=&ECODE&|HDRTXT1=&HDRTXT1";

actually has the full set of &variables inserted and ends with a double quote and semi-colon. If one of the &variables is missing then the line will be incomplete and the function will not work. This is why you should use the !IBI.AMP.varname; syntax instead of &varname with -HTMLFORM as it is less prone to error if an &variable is misspelt or missing.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Platinum Member
posted Hide Post
Mickey,

Alas the tags didn't work either. But I will start using them to be consistent.

If I determine the issue I'll post it.

Thanks,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Platinum Member
posted Hide Post
Hi Alan,

In reviewing the HTML source it appears that all is well. I cut the code from the source view and posted it below. Perhaps you can see something that I am ignorant of. Also, can you give me an example of how I should use the "!IBI.AMP.varname" syntax in lieu of what I did? I would like to use the proper methods for coding WebFocus.

var myUrl = "http://webfocus.scherer.com/ibi_apps/WFServlet?IBIAPP_app=otc&IBIF_ex=trendtxt01&USERID=341101&LOC=Albertville&ECODE=NA&HDRTXT1=ACCURACY Exception Count By Albertville Location for Period:  01/01/2008 to 01/28/2008";  


Thanks,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Virtuoso
posted Hide Post
There has to be something here. Can you just copy this code into a fex and run it and let me know what happens:
-HTMLFORM BEGIN
<html>
<head>
<title>OTC - Salesperson Trends</title>
<script type="text/javascript">
function runFex() {
var myUrl = "http://webfocus.scherer.com/ibi_apps/WFServlet?IBIAPP_app=otc&|IBIF_ex=trendtxt01&|USERID=341101&|LOC=Albertville&|ECODE=NA&|HDRTXT1=ACCURACY Exception Count By Albertville Location for Period:  01/01/2008 to 01/28/2008"; 
window.open(myUrl,'mywindow','width=400,height=600');
}
</script>
</head>
<body>
<p><a href="javascript:runFex();">Show Text Data</a></p>
</body>
</html>
-HTMLFORM END


To use the correct format for &variables, instead of &USERID use !IBI.AMP.USERID;

Always start with an exclamation mark and end with a semi-colon.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Platinum Member
posted Hide Post
Alan,

Thanks for the AMPER stuff. I'll recode my fex using the !IBI.AMP.VAR; syntax.

As per your suggestion, I also copied the code from the post into a fex and executed it. I got a web page with a link on it. Then I clicked on the link and a new web page opened size as 400x600 containing a title (ACCURACY Exception....) time/date etc. None of the data, of course. Interesting, I thought.

Thanks,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Platinum Member
posted Hide Post
Hi Alan,

Well - I recoded my fex with the !IBI.AMP stuff and still "no dice".

I also changed the javascript function to have a single line as:

  window.open('http://news.google.com','mywindow','width=400,height=600');  


Google news opens in the existing window - not a new one. Popups are working - just not from the parent fex that I have. So I'm thinking that something is getting disabled from the fex that contains the javascript window funtion or some other setting is "sticking". I'm frustrated but it's not the end of the world. Just doesn't have the cool functionality I wanted.

Thanks,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Platinum Member
posted Hide Post
Hello All,

O.K. I got it although I'm embarrassed to tell you.

I have 3 fexes - fex1, fex2, and fex3. I have been trying to get fex3 to open at a specified size in a new browser window. Fex3 was being called via Fex2.

So Fex1 executes Fex2 via a call of "window.open(myUrl, 'mywindow');" Fex2 then opens in a new window and runs. Then Fex3 is called via "window.open(myUrl, 'mywindow', 'width=200, height=300');

As you know this was not working. If I remove the 2nd parameter from the call to Fex2 as "window.open(myUrl);", Fex2 opens in a new windows and THEN when I call Fex3, Fex3 opens in a new window at the size of 200x300. It appears that using the same name for window handle was causing my issue.

At this point, I would say that this problem was self-inflicted and don't know why I didn't mention the fact that Fex2 was being called from Fex1 etc. With that information everyone would have undoubtedly provided the solution to such boneheaded code.

Please accept my humble apologies.

Thanks,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Expert
posted Hide Post
ah, but what you've stumbled on will/may be very handy in your future ... using discreet window names to control having multiple windows open. 'bonehead' becomes 'wizardry' ... Wink




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Expert
posted Hide Post
Absolutely!

Norb,

The important thing is that you tried before you came asking for help, rather than just post asking for someone to tell you how to do it without having to do much yourself.

That is the type of attitude that receives greater assistance Good One

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
Norb,

We forgive you. Smiler

We all have those kind of days every now and then that drives us nuts only to find out we did something stupid like leave off a semicolon or something simple.

At least we helped by forcing you not to give up on this since we all know it works.


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Platinum Member
posted Hide Post
Hi All,

Thanks for the understanding words. You've saved me thousands of dollars of psychotherapy.

Indeed everyone's dogged determination to assist on the issue was helped drive to the solution. Trust me, I learned some important concepts regarding IB and Javascript!

This also served to reaffirm that a great group of people actively participate in this forum. What a wonderful virtual community.

Thanks,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Expert
posted Hide Post
quote:
You've saved me thousands of dollars of psychotherapy

That'll be your round at Summit then Wink

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Master
posted Hide Post
Typically, our JS code goes through the following steps, when we need to create a popup window, containing a WebFOCUS report.:

1. Close the popup window, if necessary.
2. Construct the format of the popup window (set up a variable containing window.open() method attributes).
3. Construct the URL (call to WebFOCUS CGI).
4. Open the popup window with a ‘blank page’ via window.open() method.
5. Create a variable containing a ‘Just a moment, please’ HTML message.
6. Place the HTML message code, in the window with the document open, write, and close methods.
7. Load the WebFOCUS report URL, to the popup window, with the location.href property.




Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
 
Posts: 822 | Registered: April 23, 2003Report This Post
Platinum Member
posted Hide Post
Hi David,

That's an interesting prodedure for creating the windows. I get the concept but I'm not familiar with the document.open, write, close or the location.href etc. stuff. Would you be so kind as to post a small example that I could futz with?

Just out of curiousity, aside from the consistency that you get from steps 1-7, are there other reasons for your methodology?

Thanks,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Master
posted Hide Post
Here you go:

  
<html>
<head>
<title>Test A Popup Window</title>
<script language="JavaScript1.3">
//
// Initialize Window Properties global variable.
//
  var WProps = new String("location=no,toolbar=no,directories=no");
      WProps += ",scrollbars=no";
      WProps += ",status=no,resizable=no,top=20,left=10,width=";
      WProps += screen.availWidth - 30;
      WProps += ",height=";
      WProps += screen.availHeight - 60;
//
// Function: runrept
//  Route the report to a new popup window.
//
 function runrept () {

// Close the window, should it be open.  
  closeWindow();
 
//  Set amper variables to be passed to the report.
   vr_report   = 'somevalue';
 
//  Set pop up window parameters, based on user selections.
   menubars_yn = 'no';
   scrlbars_yn = 'no';
   heightoffset = 60;
  
// Construct format of the popup window.
  var WProps = new String("location=no,toolbar=no,directories=no");
      WProps += ",menubar=";
      WProps += menubars_yn;
      WProps += ",scrollbars=";
      WProps += scrlbars_yn;
      WProps += ",status=no,resizable=no,top=20,left=10,width=";
      WProps += screen.availWidth - 30;
      WProps += ",height=";
      WProps += screen.availHeight - heightoffset;
 
// Construct the URL call to the WebFOCUS CGI, for the report to be
// run.
  var Wurl = 'http://techsupport.informationbuilders.com';
 
// Open the popup window, with a 'blank page'.
  rptWindow = window.open("","MyWin",WProps);
 
// Place a message in the new popup window.
  var content = new String();
      content = '<font face="Verdana" color="660000" size="+1">';
      content +="Just a moment, please.<BR>";
      content +="</FONT>";
 
  rptWindow.document.open();
  rptWindow.document.write(content);
  rptWindow.document.close();
 
// Load the FOCUS report, into the popup window.
  rptWindow.location.href=Wurl;
 
 }
 
//
// Function: closeWindow
//  Close the pop-up window, if necessary.
//
 function closeWindow() {
  rptWindow = window.open("","MyWin",WProps);
  if (rptWindow && !rptWindow.closed) {
   rptWindow.close()
  }
 }
</script>
</head>
<body>
<form name="Form1" onSubmit="return flase">
<hr>
Just a test.<br>
Click OK to open a popup window.  
<hr>
</form>
<TABLE>
 <TR>
  <TD>
   <BUTTON TYPE="BUTTON" VALUE="OK" onClick="runrept();">OK</BUTTON>
  </TD>
 </TR>
</TABLE>
</body>
</html>

 
Posts: 822 | Registered: April 23, 2003Report This Post
  Powered by Social Strata Page 1 2  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     javascript - run fex in new window

Copyright © 1996-2020 Information Builders