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

get webpage url and insert into webpage <base> statement

Status
Not open for further replies.

cmgrn

Programmer
Nov 28, 2001
43
0
0
US
I am new to HTML and am writing my webpages on my pc at work then copying them into our company intranet folder for viewing.
Is there a way to specify a "keyword" that would retrieve a webpage's current location to place in the <base> statement so when I move a webpage it will automatically pick up its new location as the default?
Currently my webpages have 2 <base> statements. One for my pc and one for our intranet. I comment out the one in each webpage that is not appropriate for where the webpage is stored.

Example:

My pc:
<base href="C:\documents\forms\" />
<!--<base href=" />-->

Our intranet:
<!--<base href="C:\documents\forms\" />-->
<base href=" />

Hopefully:
<base href=[getcurrentwebpagelocation] />

Thanks.
 
That can't be done in HTML. It can be done through a server side language: ASP, PHP, ASP.NET(I think).

[monkey][snake] <.
 
Why not just use relative URLs - then it would not matter where your pages were placed, assuming you use the same structure on your dev box as on your live environment (which is normally a good thing).

E.g. instead of:

Code:
<script src="/someFolder/someAppName/js/wibble.js">

or

Code:
<a href="/someFolder/someAppName/folder2/reports/managersDelight.html">

you might use:

Code:
<script src="../someFolder/someAppName/js/wibble.js">

or

Code:
<a href="folder2/reports/managersDelight.html">

(depending on the page in question, and the size of the site, etc).

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
My dev box was Notepad and the internet until I found CoffeeCup.

I will look into both ideas. :)

Thanks for your help and time!

Mike
 
No no, by "dev box" he meant your development machine, not what you use to develop it.

And yes using relative paths is the best way to get everything to work as expected regardless of where it is placed.

To be more specific, you are making the folder the website is in the base of the website. so regardless of where that folder is located the base of the website remains constant.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top