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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting the Page URL?

Status
Not open for further replies.

cajchris

Programmer
Oct 13, 2005
57
GB
hi,

can someone please tell me how i can get the current url as it appears in the address bar.

is there someway in html i can do this? or do i need to use javascript or some other way?

regards,
cajchris
 
You can't do it just using HTML. You can do it using javascript:
Code:
<a href="javascript:alert(this.location)">Test</a>
Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
is there any way though that i can store this as a string somewhere? as i need to apply a particular style sheet depending on what the url contains

regards,
cajchris
 
maybe this faq i wrote will be helpful. it doesn't utilize the URL, but rather cookies.

faq216-6093

you could apply the concept to your url usage if needed.

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
beware of active imagination: [URL unfurl="true"]http://www.coryarthus.com/[/url]

BillyRayPreachersSonIsTheLeetestHax0rDude
[banghead]
 
or server-side code:
php super-global $_SERVER
Code:
<?php
 echo('current page:'.REQUEST_URI');
?>
similar principle applies to java, jsp, asp, cfm, perl, etc.

<marc>
New to Tek-Tips? Get better answers - faq581-3339
 
eh? I'm sure that wasn't what I meant to type...I missed the supervariable for starters!
Code:
<?php
 echo('current page:'.$_SERVER['REQUEST_URI']);
?>

<marc>
New to Tek-Tips? Get better answers - faq581-3339
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top