Reputation: 53
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"> © 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;
}
Upvotes: 2
Views: 1578
Reputation: 6669
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 ...
Upvotes: 3