javascript - Open URL with a button on a webpage -


im tying make simple site control android phone using combination of tasker , autoremote. opening link:

https://autoremotejoaomgcd.appspot.com/sendmessage?key=apa91bhfsnjn7b1egvnorooplbuiy4aifmxpkf9shm7z-xufg7dxbfur4cgc1k2nyl73fjvcb9oitnrhwubg0xz17yq8lza09rbrxcoqdkdlm-fif8w97d6jbdnjxyvnylwuzvhqzmsdmwplqk6kbqypfy6nriy8avyxkb4xqj0eiaaf6m2fkgi&message=forward

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

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -