How to include JavaScript file in Liferay Portlet?
I am not able to include http://maps.googleapis.com/m开发者_高级运维aps/api/js?sensor=false
. Whenever I load my portlet for the first time it doesn't work but if I refresh the same page then it starts working fine. I don't know what the issue is. Please Help.
One of the clean ways to include js file in a portlet, independent of the portal server is to configure in portlet deployment descriptor file as below. For liferay, it would be liferay-portlet.xml.
<portlet>
<portlet-name>MySamplePortlet</portlet-name>
<header-portlet-javascript>http://maps.googleapis.com/maps/api/js?sensor=false</header-portlet-javascript>
</portlet>
精彩评论