Know-how2.6.1 base href (since IE7) |
21.11.2008 | |
| ← 2.6 JavaScript | [ up ] - [ Know-how A - Z ] - [ top ] | 3 Databases (DBMS) → |
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:
- Know-how: JavaScript
- Reference
Tips and Tricks.
infocopter.com/know-how/javascript.html
copyright by reto - created with mytexi