Javascript in HEAD section

Javascript in HEAD section

  
Is there a way to insert javascript code inside the HEAD section of a page?
The HttpRequestHandler extension only provides an action to insert a link to a javascript file.
I want to insert code.

regards

Hi Gonçalo,

 

Why can't you include that code in the web screen javascript?

If that is not really an option you can always create an extension based on HttpRequestHandler to do that.

 

Cheers,

Tiago Simões

 

There's a javascript variable that I need to use globally on that page, and including it, doesn't seem to work.
Here's my whole problem:

I have a parent window that created a popup window using "window.open" (I can't use the popup editor because I want the popup to be independant from the parent).
I have a button on the parent window that I want to use to force the popup to close. The only way "google says" this can be done is by assigning a variable to the window.open and then using this variable to execute a window.close, but that variable needs to be global to the page.

To declare a global variable you just need to put a 

var myPopupWindow;

in the web screen javascript.

 

Cheers,

Tiago Simões

I tried that already and it didn't work. That's why I started to look for alternatives.

Make sure you put this in the web screen javascript:

var myPopupWindow;

and then when opening the popup do

myPopupWindow = window.open( ...

without the var.

I'm attaching an oml with the code I'm using and you're suggestion, but it still doesn't close the popup.

You just need to replace return true by return false in both buttons.

 

Cheers,

Tiago Simões

Thanks for the help, but I have a major problem then.
I need the return to be true, because I need to execute an action after the popup is opened.

Hi Gonçalo,

 

If you leave or resubmit the page the javascript scope will be lost.

An option would be to change the button method to Ajax.

 

Cheers,

Tiago Simões

Hi Tiago,

I put both buttons with AJAX and the popup still doesn't close.
Then, I tried another test. I reset the buttons to "submit" and took the javascript from the WebPage and put it on the Espace level. And it still doesn't work.
With the javascript at the Espace level, the scope is still lost when the page is resubmited? If so, isn't this a bug?

Hi Gonçalo,

 

No, it is not a bug, the eSpace javascript is a javascript file that will be included in all web screens but you won't be able to share state between different pages because that is not possible in javascript.

 

You need to remove the return statements from both onclick extended properties for you example to work.

 

Cheers,

Tiago Simões

Thanks for the help Tiago.
With this latest change, it now works perfectly.