Window status (to show relative URL)

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Window status (to show relative URL)

Post by Chris Corbyn »

Hi,

See this example code....

Code: Select all

<div style="width:150px; height:90px; border:1px solid black; cursor:pointer" onClick="window.location='?mode=newmode'"><a href="?mode=newmode">Switch to a new mode</a></div>
If this was in http://mysite/myfile.php then the user could click the loink to go to http://mysite/myfile.php?mode=newmode OR he/she could click the div itself to get the same result.

Only problem is that the window status bar will not show the URL the DIV is pointing to. Is there some quicky way of making it do this which is portable across domains? I am aware that window.status='http://mysite/myfile.php?mode=newmode' does it but that would not work if I moved the http://anothersite - see what I*'m trying to do?

Thanks very much :-)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can do it with a mix of code.. $_SERVER['HTTP_HOST'] is the currently queried server name. $_SERVER['HTTPS'] existing will tell you the connection is being run via HTTPS, and so forth... :: viewtopic.php?t=30090
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Nice one thanks. I'll use that idea to get the server script info then write a short JS function to decide how the URL should look.

I wondered if there may have been some kind of barely talked about function that was built into JS.... Can't be too hard to do a very good one with a bit of regexp stuff and concatenation in any case. :-)
Post Reply