Javascript onClick() function is not working for Firefox OS Mobile App

1.5k Views Asked by At

I am writing an app for Firefox OS mobile app and I am calling a Javascript function onClick() from a div attribute. Now, it works in the normal browser but when I am testing it in the simulator, the onClick function is not being called. The code's snippet is given below:

HTML codes:

      <script type = "text/javascript" src="app.js" defer></script>
      <script src = "jquery-2.1.1.min.js"></script>
      <script language = "javascript"></script>
      <link rel="stylesheet" type="text/css" href="app.css">
    </head>

<body>
<div id="page1" onclick = "eventListener()";>
<header id = "page1_header"> </header>        

    <div id = "page1_empty_space"></div> 

    <center id="page1_circle">
        <div class="circle"><img src='icons/page1_logo.jpg'id="page1_pic"></div>
  </center>

    <div id = "page1_a">
    <p1 id="page1_p1"> Click to Continue </p1>      
    </div>

    <footer id="page1_footer">
        <p id="page1_p"> &copy 2014</p>
    </footer>
 </div>

Javascript functions:

 function eventListener()
 {
    alert("on event listener");
    window.addEventListener = disableFirstPage();

 }
 function disableFirstPage() 
 {
     alert("disableFirstPage()");   

     timeout = setTimeout(PageJumping("page2"),5000); //Jump to Page 2

     disableTimeOut(timeout);
 }

 function PageJumping(x)
 {  
     alert("Jumping to "+x);
     window.location.hash = x; 
 }
1

There are 1 best solutions below

2
On BEST ANSWER

Since you have jQuery loaded, try use it to invoke the click event on the #page1.

Wrap the eventListener function around $(document).ready(); like this

$(document).ready(function(){
  $("#page1").on('click',eventListener());
});

//other functions continued ...