I want to make a page where JavaScript will do something like:
When i click a link named "update" it will hide the div named "hide" run another script that is linked by JavaScript.
But when i click "Update" it just hide the div but doesn't run the script on mobile or Firefox. It's working on Google Chrome.
var myLink = document.getElementById('mylink');
myLink.onclick = function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "js/wa_lock.js.";
document.getElementsByTagName("head")[0].appendChild(script);
return false;
}
$("#mylink").click(function () {
$("#hide").hide();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="hide">
<h1 class="big">Update Required!</h1>
<div class="wrapper">
<img src="images/logo.png" class="logo" />
<p class="txt">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p class="txt">Nullam sit amet mauris pellentesque, fermentum lacus vitae, ultrices ligula. Praesent odio dui, volutpat id faucibus non, facilisis eget lacus.</p>
<img src="images/msg.png" class="logo" />
<p class="now">facilisis eget lacus <span id="timer"></span> Vivamus hendrerit velit purus</p>
<div class="bottom">
<p class="rules">1.Curabitur quis dolor ligula. Nullam erat neque, ornare nec massa quis, blandit dignissim tortor. Sed velit lacus, tempus quis lorem sed, efficitur mattis justo.</p>
<p class="rules">2. Donec mattis, nibh eu porttitor lobortis, erat neque placerat orci, ac egestas velit arcu eu augue. Morbi viverra sapien in ultricies pulvinar.</p>
<a href="#" id="mylink">Update</a>
</div>
</div>
</div>
wa_lock.jsin the page directly, but encapsulate the logic in it within a function which you can call when the click event happens.