Adding an onclick function to go to url in javascript?
Adding an onclick function to go to url in javascript?
I am using this fancy little JavaScript to highlight a field as the user hovers over it. Could you please tell me if there is a way of adding an onclick function which will act as a link and go to a URL?
Answer by Rick Donohoe for Adding an onclick function to go to url in javascript?
Try
window.location = url;
Also use
window.open(url);
if you want to open in a new window.
Answer by T.W.R. Cole for Adding an onclick function to go to url in javascript?
function URL() { location.href = 'http://your.url.here'; }
Answer by SubstanceD for Adding an onclick function to go to url in javascript?
In jquery to send a user to a different URL you can do it like this:
$("a#thing_to_click").on('click', function(){ window.location = "http://www.google.com/"; });
this way will work too but the above is the newer more correct way to do it these days
$("a#thing_to_click").click(function(e){ e.preventDefault(); window.location = "http://www.google.com/"; });
Answer by Nigel for Adding an onclick function to go to url in javascript?
Not completely sure I understand the question, but do you mean something like this?
$('#something').click(function() { document.location = 'http://somewhere.com/'; } );
Answer by Aamir Shahzad for Adding an onclick function to go to url in javascript?
Simply use this
onclick="location.href='pageurl.html';"
Answer by Moji for Adding an onclick function to go to url in javascript?
HTML
MVC
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
0 comments:
Post a Comment