I want something like this:
function goTo (String string)
{
window.location.href = string;
}
and access it with button click.. like:
<button class="button" onClick="home(" My target url/file directory ")">Test</button>
Is it possible?
I want something like this:
function goTo (String string)
{
window.location.href = string;
}
and access it with button click.. like:
<button class="button" onClick="home(" My target url/file directory ")">Test</button>
Is it possible?
You can't have double quotes inside double quotes, use single quotes instead:
<button class="button" onClick="home(' My target url/file directory ')">Test</button>
You're on the right path:
function goTo(url) {
window.location.href = url;
}
<button onClick="goTo('http://www.stackoverflow.com')">Test</button>
yes, just that you need to tweak your code a little bit, fiddle
Function arguments doesn't need a type
function goTo ( string)
{
window.location.href = string;
}
Finally, you need to escape inner double quotes
<button class="button" onClick="goTo ('My target url/file directory')">Test</button>
Okay so I got it working this way:
function locationUrl (string) {
window.location.href = string;
}
<button class="button" onClick="locationUrl("#")">Test</button>
Thanks to you all!