• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

how to call a url using on click event

Hi,

How to call  an  url or a page  from a Jquery  on click event.


Thank you
0
roy_sanu
Asked:
roy_sanu
1 Solution
 
chaitu chaituCommented:
$('#Test').click(function() {
  window.location = 'http://www.google.com'
  return false;
});
0
 
Marco GasiFreelancerCommented:
window.loaction returns the actual url. You have to use one of the following:

window.location.assign('http://www.google.com');
or
window.loacation.href = 'http://www.google.com';
or
window.loacation.replace = 'http://www.google.com';

$('#Test').click(function() {
  //choose one and uncomment it
  //window.location.assign('http://www.google.com');
  //window.loacation.replace = 'http://www.google.com';
  window.loacation.href = 'http://www.google.com';
  return false;
}); 

Open in new window

0
 
roy_sanuAuthor Commented:
suppose i have a url path such as /jsp/user.html

can i use like this

$('#Test').click(function() {
  window.location = "/jsp/user.html"
  return false;
});
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
chaitu chaituCommented:
yes.

or you can use window.location.href = "/jsp/user.html"
0
 
Marco GasiFreelancerCommented:
I'm sorry: I always used window.location only to get current page url :-(
I sign off from this question, now.
Cheers
Marco
0
 
RawbinCommented:
You can use like this:

<button onclick="myFunction()">Click to Open New Window</button>

<script type="text/javascript">
function myFunction() { window.open('www.sample.com', '_blank', 'toolbar=1,location=0,menubar=0'); }
</script>

www.sample.com => your website
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now