PDA

View Full Version : I have a script that has this on the same page



ajfmrf
12-28-2011, 01:17 AM
<script language="javascript" type="text/javascript">
function root_path() {return('../../');}
</script>


Can someone explain what this is and how it works.

Thanks,

Bud

Nile
12-28-2011, 06:45 AM
All this function does is return a string.

For example:


alert(root_path()+"styles/images");

Would alert: ../../styles/images.

This should really be kept in a variable like so:


var root_path = "../../";

And then you would have to go around changing all the places that it uses it as a function.

The function was probably made so that the programmer could access the root path (the root directory) faster without having to type ../../ everytime.

ajfmrf
12-29-2011, 04:25 AM
Is is a different way of using base href?


<head>
<base href="http://www.w3schools.com/images/" target="_blank" />
</head>

Nile
12-29-2011, 04:53 PM
I don't think there is.