掲示板

adding external JavaScript to a Web Content Display

11年前 に jean-pierre salazar によって更新されました。

adding external JavaScript to a Web Content Display

New Member 投稿: 3 参加年月日: 12/10/29 最新の投稿
Hello,
I am brand new with Liferay 6, so please bare with me on this issue.
I am trying to implement external JavaScript files to a simple web content display block that I created on my page, but for some reason my JavaScript come back with errors (I added my external js links in the portal-normal head). The external JavaScript files work perfect when I link them to a simple hand coded HTML page but when I try to use it in Liferay, errors show up.
Can somebody give me a step-by-step how to fix this issue?
Thank you in advance!
JP
11年前 に Roshan Qureshi によって更新されました。

RE: adding external JavaScript to a Web Content Display

Regular Member 投稿: 159 参加年月日: 10/08/24 最新の投稿
Hi,

Please follow below steps :
1) put your js files in themes/your-theme/docroot/_diffs/js
2) create a web content using source button means click on source button and you can write full html code.
Write html having <script> in the same way we are using in normal html
3) deploy theme
4) publish content

Regards,
Roshan
11年前 に jean-pierre salazar によって更新されました。

RE: adding external JavaScript to a Web Content Display

New Member 投稿: 3 参加年月日: 12/10/29 最新の投稿
thanks for replying.
But now the problem is the following:
Looks like the web content display can find the path, but I get these following JavaScript errors:

"uncaught TypeError: Object function element (){[native code]} has no method implement" and
"uncaught ReferenceError: Class is not defined"

Please help ;)

Thank you
thumbnail
11年前 に Pranay R Patadiya によって更新されました。

RE: adding external JavaScript to a Web Content Display

Regular Member 投稿: 177 参加年月日: 10/02/23 最新の投稿
Hi,

Steps:
1) Import JS file to document library.
2) Get the URL of that particular JS file from document library portlet.
3) Import JS file from URL which you get in step-2 and code your Java script functions.

Let me know if you have any query/concern in above mentioned steps.

Regards,
Pranay
11年前 に jean-pierre salazar によって更新されました。

RE: adding external JavaScript to a Web Content Display

New Member 投稿: 3 参加年月日: 12/10/29 最新の投稿
I try to upload the JS files to the document folder but I get an uploading error.
Even if I add a simple JS function to my web content display HTML, it won't take it. The script will not work.
I wonder why that is.

Thanks
JP