I'm trying to generate a JS function which will allow me to add the domain of the server the script is written in. This is because the same code is used on multiple servers, but I need to force the request to a specific domain. I also need the JS to write the HTML which will be used in the navigation. So far I have come up with the following, which doesn't seem to work...
-- this is the function which generates the HREF
<script language="JavaScript"><!--
function String displayURL(page,linkText) {
var domain = ' var linkText = '<a href="'+domain+page'>'linkText'</a>';
return linkText;
}
--></script>
--this is the bit that should write it to the page
<script language="JavaScript">
document.write(displayURL(index.html,hello));
</script>
does anyone know why it isn't working?
-- this is the function which generates the HREF
<script language="JavaScript"><!--
function String displayURL(page,linkText) {
var domain = ' var linkText = '<a href="'+domain+page'>'linkText'</a>';
return linkText;
}
--></script>
--this is the bit that should write it to the page
<script language="JavaScript">
document.write(displayURL(index.html,hello));
</script>
does anyone know why it isn't working?