how to add a url to onclick event in javascript code example Example: onclick url <button onclick="location.href='logout.php';">logout</button>