I was wondering how I would be able to execute a command such as this in javascript. I just want to store the url as a string in a variable and redirect them to it when the time comes -
var linkz = "http://www.google.com/";
window.location.href= linkz;
Why doesn't this work?
Thanks,
If you're using links this way (as mentioned in a comment):
<a href="javascript:checkCk(google.com)">Google</a>
Then the problem is that you're not passing a string to your checkCk()
function.
Try this:
<a href="javascript:checkCk('http://google.com')">Google</a>
The code you used for window.location.href
should work.
At this point, I don't see why you'd use javascript if all you're doing is replacing the default behavior of the link.