A little help with some (simple) Javascript code

I'm a newbie when it comes to javascript. Maybe someone can help me with this. I guess it is not very difficult. Here's what I would like:

<SCRIPT type=text/javascript>
    var StandardURL = "http://site/Lists/test/AllItems.aspx";
</script>

<SCRIPT type=text/javascript>
    var FilterURL = "http://site/Lists/test//AllItems.aspx?FilterField1=Judge&FilterValue1=";
</script>

      

var DynamicURL = FilterURL + DynamicUserInf

(the gap between it shouldn't be like one url link) dynamicuserinf contains a different value depending on the user, which doesn't need to worry about what's in it. It already contains the value for these runs

var CurrentURL = current URL where this script is loading

<script language="JavaScript" type="text/javascript">
    if (CurrentURL == StandardURL) { location.href= (DynamicURL);}
</script>

      

ElSE does nothing (I assume this is not done with just one if statement)

I hope this is not a big problem.

+2


source to share


1 answer


To get the current url:

var CurrentURL = document.URL;

      



For concatenating / concatenating variables (assuming DynamicUserInf is a variable), you already got it right :)

var DynamicURL = FilterURL + DynamicUserInf;

      

+2


source







All Articles