You are here iC Home > Know-how > JavaScript > base href (since IE7)

Know-how

2.6.1 base href (since IE7)

07.10.2008

2.6 JavaScript [  up  ] - [ Know-how A - Z ] - [ top ] 3 Databases (DBMS)

X X X X

Get/Set <base href=""> with JavaScript?

Is it possible to get and set the <base href=""> tag in an HTML page with JavaScript? Even just to get the href would be helpful. Using a jump menu, the JavaScript does not seem to take the document base into consideration when processing links.

The answer at experts-exchange ist not useful at all. See this example instead:
<script language="JavaScript">
document.getElementsByTagName("base")[0].href = "http://www.example.com/know-how/mediawiki-reference/";
</script>
Please take note it's necessary to set an initial base href value if you want to modify its value at page load time.


See also:




copyright by reto - created with mytexi