I am new to javascript, but is this valid?
<script type="text/javascript">
if (condition()) {
location = "http://example.com/foo/bar/baz";
}
function condition()
{
if(something)
return true
else
return false
</script>
I am trying to write a javascript that goes insdie of co开发者_如何学Cntent editer web part inside of SharePoint. Thanks.
It's almost valid (needs a closing }
), you can call a function in or as an if()
condition.
It should have the }
on the end:
function condition() {
if(something)
return true;
else
return false;
}
Or much simpler:
function condition() {
return something;
}
You can test it here.
No, your missing a } at the end of your condition function.
No, but this is:
<script type="text/javascript">
if (condition()) {
location = "http://example.com/foo/bar/baz";
}
function condition()
{
if(something)
return true;
else
return false;
}
</script>
No, You need a closing curly bracket on your function.
精彩评论