/    Sign up×
Community /Pin to ProfileBookmark

hide text from a certain ip.

Is there a way to hide just one line of text from a specific user?

Here’s how I think you’d do it, but am not sure how to actually code it:

write a javascript if statement that says if its ip “insert number here” then toggle the visibility of a div that has the text to hidden.

Is this possible?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@StashXJan 22.2005 — The problem is that you can't get the ip using Javascript so

you have to find a script suite to your server(PHP,ASP...) using [URL=http://www.google.com/search?q=javascript+IP+blocker]Google[/URL]

then it's easy if you have a var named ip with the user's ip...

[CODE]
<html>
<head>
<title>IP block</title>
</head>
<body>
<div id="ipdiv">HELLO</div>
<script language="JavaScript">

var ip='198.164.214.231'; // user's ip found with not javascript script

var blockedip=new Array(); // all the ips that can't read the text in ipdiv
blockedip[0]='198.124.45.12';
blockedip[1]='198.164.214.231';
blockedip[2]='143.255.149.201';

for(var i=0;i<blockedip.length;i++){
if(ip==blockedip[i]){
ipdiv.innerHTML="";
ipdiv.style.visibility="hidden";

}
else{
ipdiv.visibility="";
}
}

</script>
</body>
</html>
[/CODE]
×

Success!

Help @susancbk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...