show hide navigation links based on server names

R

Ray

Hi,
I was wondering if anyone has any idea how this can be done. I am
trying to show/hide navigation links based on server names or ip
addresses. So if, someone visits a particular url/ip address he/she
sees only a particular set of navigation links. I am sure this can be
done using some kind of Java script or VB script, just not sure how.
I have two servers with different server names and IP addresses. Based
on user's input I need to display the hyperlinks which then directs the
user to other utilities. For this I need to create a script which takes
the user input and show/hide those link based on server name or ip
address.
for example -if the user types in- http://wxyz.com or 166.xx.xx.01 then
only two hyperlinks will be shown but if the user inputs-
http://uvwx.com or 166.xx.xx.02 then we want to show all the
hyperlinks.
Thank you
Ray
 
M

Mick White

Ray said:
Hi,
I was wondering if anyone has any idea how this can be done. I am
trying to show/hide navigation links based on server names or ip
addresses. So if, someone visits a particular url/ip address he/she
sees only a particular set of navigation links. I am sure this can be
done using some kind of Java script or VB script, just not sure how.
I have two servers with different server names and IP addresses. Based
on user's input I need to display the hyperlinks which then directs the
user to other utilities. For this I need to create a script which takes
the user input and show/hide those link based on server name or ip
address.
for example -if the user types in- or 166.xx.xx.01 then
only two hyperlinks will be shown but if the user inputs-
http://uvwx.com or 166.xx.xx.02 then we want to show all the
hyperlinks.

As far as javascript, the URL is exposed as: << window.location >>, but
seems to me you should do this server side.

x=window.location,y=yourRefToElement;
if(
x && (x== "http://wxyz.com" || x=="166.xx.xx.01")
)
{
if( y && y.style){
y.style.display="none";
}
}

Mick
 
R

Ray

Thanks for the reply guys. I do not need to do redirect. I just want to
display a particular set of hyperlink if the user enters one url name
or IP address a display another set of hyperlinks if the user enters
another url name or IP address.
I want to do this using javascript or vb script.
Appreciate all the help.
Ray
 
R

RobG

Ray said:
Thanks for the reply guys. I do not need to do redirect. I just want to
display a particular set of hyperlink if the user enters one url name
or IP address a display another set of hyperlinks if the user enters
another url name or IP address.
I want to do this using javascript or vb script.
Appreciate all the help.
Ray

The following hideLinks function hides any link that doesn't match the
domain passed to it. How you get the domain is up to you, I've used an
input, but some other method could be used (say document.domain), radio
buttons, etc.

An empty string will show all links.


<head>
<title>link play</title>

<style type="text/css">
a {display: block;}
</style>

<script type="text/javascript">
function hideLinks( d ) {
if ( !document.links || !document.body.style ) return;
var x = document.links;
var i = x.length;
while ( i-- ) {
x.style.display = ( x.href.match(d) )? '' : 'none';
}
}
</script>

</head>
<body>
<form action="">
<input type="text" width="50" name="aDomain" value="wxyz.com">
<input type="button" value="Show/hide links" onclick="
hideLinks(this.form.aDomain.value)
">
</form>

<a href="http://wxyz.com">
link to http://wxyz.com/A or 166.xx.xx.01/A</a>
<a href="http://wxyz.com">
link to http://wxyz.com/B or 166.xx.xx.01/B</a>
<a href="http://uvwx.com">
link to http://uvwx.com/A or 166.xx.xx.02/A</a>
<a href="http://uvwx.com">
link to http://uvwx.com/B or 166.xx.xx.02/B</a>
</body>
 
R

Ray

Thanks for your reply. I am using
strServerName = request.serverVariables("Server_Name")
to get the Server name. Any idea how I can do this server side using
ASP.
Thank you
Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,653
Latest member
YvonneJif

Latest Threads

Top