Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Javascript - Get Parameter from this.window.name and Use it In Fex
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] Javascript - Get Parameter from this.window.name and Use it In Fex
 Login/Join
 
Platinum Member
posted
Hello,

I'm trying to automatically get the "this.window.name" function to populate in a parameter in my fex. At the moment, all I am able to do is get this to work by calling the variable via onclick. My problem is separated into two items:

1. How do I get javascript to run onload within a .fex?
2. How do I pass the variable set in javascript back to an & variable that the .fex can read?

Here's the code I'm working with so far.

 TABLE FILE CAR
HEADING
"CLICK HERE"
PRINT CAR NOPRINT
WHERE RECORDLIMIT EQ 1
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
TYPE=HEADING,JAVASCRIPT=SAVEDAT(),$
ENDSTYLE
END
-RUN
-HTMLFORM BEGIN
<html>
<script language="javascript">
function SAVEDAT()
{
var usrid=parent.MyHTMLParmsPage = this.window.name;

alert(usrid);
}
</script>
</html>
-HTMLFORM END 


Thanks in Advance!!

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8204
 
Posts: 104 | Registered: July 10, 2018Reply With QuoteReport This Post
Expert
posted Hide Post
There are so many ways to do this.

Simplest (not knowing what you are trying to do) would be to move the HTML to before the report and remove the function container, just run the js.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.06OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6252 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Hey Waz,

Thank you very much for your response. so if I just put this at the beginning of the report, it looks like nothing runs. Am I doing something wrong? Do I need to use a different function?

What function would I use to pass the var usrid to something WebFOCUS could read?

-HTMLFORM BEGIN
<html>
<script language="javascript">
function SAVEDAT()
{
var usrid=parent.MyHTMLParmsPage = this.window.name;

alert(usrid);
}
</script>
</html>
-HTMLFORM END 
 


Thanks in advance!


WebFOCUS 8204
 
Posts: 104 | Registered: July 10, 2018Reply With QuoteReport This Post
Expert
posted Hide Post
Like this
-HTMLFORM BEGIN
<html>
<script language="javascript">
var usrid=parent.MyHTMLParmsPage = this.window.name;

alert(usrid);
</script>
</html>
-HTMLFORM END 


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.06OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6252 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Thank you Waz, didn’t see your point about removing the function earlier. How about reading the parameter in the .fex in WebFOCUS? Is there a function that needs to happen? I know there’s some html ibi.amp thing that you put in the code.

Is there a better way to read the current portal page other than this.window.name btw?

Thank you for your help.


WebFOCUS 8204
 
Posts: 104 | Registered: July 10, 2018Reply With QuoteReport This Post
Expert
posted Hide Post
Here is where is get tricky.

There are possibly other ways to do it, but my suggestion for simplicity sake is to call your fex with the parameter from the HTML page, passing the name.

Something like this.

-HTMLFORM BEGIN
<html>
<script language="javascript">
window.location = '/ibi_apps//run.bip?BIP_REQUEST_TYPE=BIP_LAUNCH&|BIP_folder={IBFS Location}&|BIP_item={fexname}&|PAGENAME='+this.window.name ;
</script>
</html>
-HTMLFORM END 


The fex will get the window name in the variable &PAGENAME


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.06OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6252 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Wow Waz, thank you very much for your response here. I saw another post where you talked about this briefly and I knew you knew what to do here


WebFOCUS 8204
 
Posts: 104 | Registered: July 10, 2018Reply With QuoteReport This Post
Platinum Member
posted Hide Post
I’ll try this out next week when I get back from vacation and hopefully can close this out. Appreciate it!!


WebFOCUS 8204
 
Posts: 104 | Registered: July 10, 2018Reply With QuoteReport This Post
Master
posted Hide Post
quote:
<script language="javascript">


For what it's worth, language="javascript" is not a valid attribute for a script element. The proper attribute is a JavaScript MIME type like this:
 <script type="text/javascript"> 


With that said, the HTML5 specification urges authors to omit the attribute rather than provide a redundant MIME type. So that means that all you need is <script> and you're good to go.


Hallway
WF(Prod):8202M1
WF(Test):8202M4
OS/Platform:Win 10
Outputs:All
 
Posts: 559 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Master
posted Hide Post
quote:
call your fex with the parameter from the HTML page, passing the name


Using Waz's suggestion, you could also use an iframe by passing the variable in the uri of the iframe src, and not have to redirect the html page
  
-HTMLFORM BEGIN NOEVAL
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #report1{
            width:100vw;
            height:100vh;
        }
    </style>
</head>
<body>
    <iframe src="" frameborder="0" id="report1"></iframe>
    <script>
        const path = `/ibi_apps/run/ibfs`;
        const ibfs_path = `IBFS:/WFC/Repository/domain/fileNmae.fex`;
        const usrid = parent.MyHTMLParmsPage = this.window.name;
        const uri = `${path}?IBFS_path=${ibfs_path}&usrid=${usrid}`
        document.querySelector('#report1').src = uri;
    </script>
</body>
</html>
-HTMLFORM END

This message has been edited. Last edited by: Hallway,


Hallway
WF(Prod):8202M1
WF(Test):8202M4
OS/Platform:Win 10
Outputs:All
 
Posts: 559 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Platinum Member
posted Hide Post
I never got around to being able to try this. Thank you so much for responding and for all the help here! This is awesome!


WebFOCUS 8204
 
Posts: 104 | Registered: July 10, 2018Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Javascript - Get Parameter from this.window.name and Use it In Fex

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.