Solved

how to call a url using on click event

Posted on 2014-04-11
6
248 Views
Last Modified: 2014-04-16
Hi,

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


Thank you
0
Comment
Question by:roy_sanu
6 Comments
 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 500 total points
ID: 39993877
$('#Test').click(function() {
  window.location = 'http://www.google.com'
  return false;
});
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39994004
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
 

Author Comment

by:roy_sanu
ID: 39994020
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 39994067
yes.

or you can use window.location.href = "/jsp/user.html"
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39994116
I'm sorry: I always used window.location only to get current page url :-(
I sign off from this question, now.
Cheers
Marco
0
 

Expert Comment

by:Rawbin
ID: 39996133
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now