cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

adding a .js file

Former Member
0 Likes
432

Hi all,

I would like to create a central javascript file for my project, and include it in every JSP.

1. I am assuming that the script file should go in the sister directory of the image folder. Is that true?

2. Can anyone provide the code to include this file. With htmlb generating html for me, I sometimes get confused where to put things.

thanks in advance for your help

Mariana

View Entire Topic
Former Member
0 Likes

Hi Mariana,

Put it under following folder.

dist->

scripts

String url = componentRequest.getWebResourcePath() + "/scripts/xx.js";

PS: Please award points if i am of any help to you. thank you.

Message was edited by: Prakash Singh

Former Member
0 Likes

Thank you Prakash,

I thought that might be it, since it is the way we access images too.

Just 2 quick questions if anyone can help?

I would like this file to be common to the portal, not to just the iview. Is there anywhere in the portal that I could put this file to be available to ALL my jsps, regardless of which project they are in. Sort of like a server/common/scripts directory?

Thank you in advance

Mariana

Former Member
0 Likes

Hey prakash,I have a similar situation.

I have a .js file that stores client eventing which is same for several other Iviews.I have imported that file into dist>scripts folder.

I have used the line u pasted in this post.

If i use a function defined in the .js file, it gives me an error.

<a href ="javascript:sayHi()" >Click here</a>

i get a script error: sayHi not defined.

am i missing something else?

Thanx.

Former Member
0 Likes

Hi Peter,

You need to include a line such as this:

<script type="text/javascript" language="JavaScript1.1" src="http://ar.atwola.com/file/adsWrapper.js"></script>

where you want to include your js file.

Hope that helps,

Yoav.