Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/07/2015, 19:06
dacroma
 
Fecha de Ingreso: mayo-2013
Ubicación: bogota
Mensajes: 157
Antigüedad: 11 años
Puntos: 2
Agregar un archivo JavaScript a JSF

Buenas noches compañeros del foro.
Es que quisiera agregar una archivo JavaScript a una pagina web que estoy haciendo con JAVA JSF.

Código Java:
Ver original
  1. <html xmlns="http://www.w3.org/1999/xhtml"
  2.       xmlns:h="http://java.sun.com/jsf/html"
  3.       xmlns:ui="http://java.sun.com/jsf/facelets">
  4.     <h:head>
  5.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  6.        
  7.         <script type="text/javascript" src = "JSProductos.js" language="javascript"></script>
  8.         <title>Facelet Title</title>
  9.     </h:head>
  10.     <h:body>
  11. </h:body>
  12. </h:html>

y para probarla utilizo el JSProductos.js pero no funciona:

Código Javascript:
Ver original
  1. addEvent(window,"load",inicio,false);
  2.    
  3.     function inicio(){
  4.         alert("hola");
  5.     }
  6.  
  7.  
  8. function addEvent(elemento,evento,metodo,estado){
  9. if(elemento.attachEvent)
  10. elemento.attachEvent("on"+evento,metodo);
  11. else
  12. if(elemento.addEventListener)
  13. elemento.addEventListener(evento,metodo,estado);
  14. }