[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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