javascript - Open URL with a button on a webpage -
im tying make simple site control android phone using combination of tasker , autoremote. opening link:
will make phone "forward". have 4 buttons, forward, left, right, back. simple school project person wearing blind fold controlled phone saying directions.
i need button open url not go site or leave site. posable?
you use javascript send ajax request in background page.
in html have this:
<input type="button" value="forward" class="movement-btn-f" /><br /> <input type="button" value="back" class="movement-btn-b" /><br /> <input type="button" value="left" class="movement-btn-l" /><br /> <input type="button" value="right" class="movement-btn-r" />
then in javascript, this:
$(document).ready(function() { $('.movement-btn-f').click(function() { $.get("your forward url here"); }); $('.movement-btn-b').click(function() { $.get("your url here"); }); // etc... });
to use you'd need include jquery library (see: http://www.jquery.com).
you might want check out documentation (http://api.jquery.com/jquery.get/) , see how use success callback wait command sent , block others in meantime, depends on application.
Comments
Post a Comment