By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,678 Members | 2,021 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,678 IT Pros & Developers. It's quick & easy.

show hide navigation links based on server names

P: n/a
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

Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Ray wrote:
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

Jul 23 '05 #2

P: n/a

What webserver are you running? Most do redirects, if using Apache, you
can use RedirectMatch directive on the server daemon, it takes a regexp as
the client-requested url and redirects accordingly, and yes, server sided
will be optimal for this. Apache I do know does RedirectMatch, but I'm
sure is not the only one.

Danny

On Tue, 21 Jun 2005 17:55:01 -0700, Ray <re*****@yahoo.com> wrote:
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


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #3

P: n/a
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

Jul 23 '05 #4

P: n/a
Ray wrote:
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[i].style.display = ( x[i].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>
--
Rob
Jul 23 '05 #5

P: n/a
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

Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.