Page 1 of 1

Window status (to show relative URL)

Posted: Fri Feb 11, 2005 4:08 am
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 :-)

Posted: Fri Feb 11, 2005 4:19 am
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

Posted: Fri Feb 11, 2005 2:35 pm
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. :-)