Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate FQDN Function

Status
Not open for further replies.

evilbox

IS-IT--Management
Jan 7, 2001
6
GB
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=&quot;JavaScript&quot;><!--
function String displayURL(page,linkText) {
var domain = ' var linkText = '<a href=&quot;'+domain+page'>'linkText'</a>';
return linkText;
}
--></script>


--this is the bit that should write it to the page
<script language=&quot;JavaScript&quot;>
document.write(displayURL(index.html,hello));
</script>

does anyone know why it isn't working?
 
pretty close, just some syntax errors and you shouldn't have a local var by the same name as an argument.

try this:

Code:
<script language=&quot;JavaScript&quot;>
<!--
function displayURL(page,linkText) {
    var domain = '[URL unfurl="true"]http://www.specificdomain.com/';[/URL]
    var link = '<a href=&quot;'+domain+page+'&quot;>'+linkText+'</a>';
    return link;
}
//-->
</script>


=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top