/    Sign up×
Community /Pin to ProfileBookmark

Javascript – Show on URL

Hello,

I hope somebody can help me I have been at this for hours. I am new to JavaScript.

I need a script to show a layer of hidden content only when on a certain URL. I have searched and found nothing, is this possible to do ?

Example:

[url]http://mydomain.com/index.php?1[/url] = content = hidden
[url]http://mydomain.com/index.php?2[/url] = content = show

(The content is basically a table of text)

I did find the following script (below) which pulls the current URL from the browser. but have no clue how to do this

<script language=”JavaScript”>
var URL = unescape(location.href) // get current URL in plain ASCII
var xstart = URL.lastIndexOf(“”) + 1
var xend = URL.length
var hereName = URL.substring(xstart,xend)
var herePath = URL.substring(0,xstart)
document.write(“The name of the current file is: ” + hereName)
document.write(“The path of the current file is: ” + herePath)
</script>

Any help would be great!

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 07.2006 — [code=php]
<script type="text/javascript">
onload=function(){
var q = location.href.split('?')[location.href.split('?').length-1];
document.getElementById('mydiv').style.display=(q=='2')?'block':'none';
}
</script>
[/code]
Copy linkTweet thisAlerts:
@spiff12authorMay 07.2006 — [code=php]
<script type="text/javascript">
onload=function(){
var q = location.href.split('?')[location.href.split('?').length-1];
document.getElementById('mydiv').display=(q=='2')?'block':'none';
}
</script>
[/code]
[/QUOTE]


Hi Kor,

Thanks for the script would is be possible to do by IP address ?

if hidden layers could be made viewable based on the users IP

that would be even better. Would that be possible ?

Thanks for the help!
Copy linkTweet thisAlerts:
@KorMay 07.2006 — 

Nope. Not with javascript alone. Only a server-side application can detect user's IP.
--------


I have mistyped something:

document.getElementById('mydiv').[COLOR=Blue]style[/COLOR].display=(q=='2')?'block':'none';
×

Success!

Help @spiff12 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 5.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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