Solved

how to call a url using on click event

Posted on 2014-04-11
6
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
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!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article discusses how to implement server side field validation and display customized error messages to the client.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The viewer will learn how to dynamically set the form action using jQuery.

733 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