Jump to content

base href


franky
 Share

Recommended Posts

Hi allI have a base href <!-- commented out --> in my htm files - as of:<!-- <base href="http://www.somewhere_where_my_files_are/"> -->and am using local references like:<a href="project2b.htm#top3"><img style="border: 0px solid ; width: 229px; height: 37px;" alt="" title="Linky" src="3.gif"></a>to edit and browse the files locally on my pc.I think I know that if I upload the files with the base hred uncomented - the browser will look for the project2b.htm and gif at the base folder's path.What I'm after is to be able to change my css file only - to change the base href's path - instead of having to change it within each and every file's <head> - can some one help me out?

Link to comment
Share on other sites

You're not going to be able to do that with CSS, but you may be able to do it with java script:

function changeBase(){	var base = document.getElementsByTagName("base")[0];		if(base)		{			base.href = "http://somedomain/somedirectory/";		}}window.onload = changeBase;

If you saved that in an external javascript file and included a reference to it on all of your pages, it might work for you. The only reason I say might is because I've never done this with the "base" element and I don't know if the DOM behaves the same with it as it does with all the other elements. It'd be worth a try though.

Edited by jesh
Link to comment
Share on other sites

You're not going to be able to do that with CSS, but you may be able to do it with java script:
function changeBase(){	var base = document.getElementsByTagName("base")[0];		if(base)		{			base.href = "http://somedomain/somedirectory/";		}}window.onload = changeBase;

If you saved that in an external javascript file and included a reference to it on all of your pages, it might work for you. The only reason I say might is because I've never done this with the "base" element and I don't know if the DOM behaves the same with it as it does with all the other elements. It'd be worth a try though.

Thanks for the info jesh - it was worth a try (asking) - don't like javascript too much (security) but may give it a go.Thanks again.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...