This is a discussion on "Javascript to change Base href?" within the JavaScript Forum section. This forum, and the thread "Javascript to change Base href? are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Javascript to change Base href?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Javascript to change Base href?
Is there a way to use javascript to change the base href at one point in the document, then change it back to the original? I need to do it for some images.
|
|
|
|
#2
|
|||
|
|||
|
Re: Javascript to change Base href?
Depending at which point you mean, it may be better to do this with CSS.
Could you post some example code? |
|
#3
|
|||
|
|||
|
Re: Javascript to change Base href?
You can use the setAttribute property which is pretty straightforward. What exactly are you doing though, I don't really follow.
Pete. |
|
#4
|
|||
|
|||
|
Re: Javascript to change Base href?
Quote:
thanks. edit: just tried it, nope, didn't work.
Last edited by Zonglars; Jul 25th, 2007 at 11:25. |
|
#5
|
|||
|
|||
|
Re: Javascript to change Base href?
This won't work, because base href is a global attribute for the document. At best, changing it will break all your other links!
|
|
#6
|
|||
|
|||
|
Re: Javascript to change Base href?
ah, okay, thanks, i'll just stick with photobucket 'till i get more space and bandwidth for my site (i already have more than enough, but just to be safe)
|
|
#7
|
|||
|
|||
|
Re: Javascript to change Base href?
I'm not exactly sure what needs to happen but I wrote the following anyway:
http://www.swallow.net.au/temp/fourPics.htm I've put all my thumbnails in one bitmap that's 400px wide by 100px high. This way I don't have to worry about preloading all the thumbnails. Then set the bitmap to the background and just adjusted the background position for each div. Saves code, no preloading and you can use JS to change the css if you need the background pos to change at a certain point. Still I may have completely missed the point here. Last edited by AndrewFelix; Jul 26th, 2007 at 05:24. |
|
#8
|
|||
|
|||
|
Re: Javascript to change Base href?
oh, you did.
i'm talking about the base tag in the header, that sets the default url for relative links and optionally the default target for links. i have know clue what you thought i meant |
|
#9
|
|||
|
|||
|
Re: Javascript to change Base href?
ha ha...I obviously got that completely arse up. My brain was pretty scattered yesterday.
|
|
#10
|
||||
|
||||
|
Re: Javascript to change Base href?
In full agreement with Mike, I have to re-iterate what he said....
I.e... the BASE attribute is applied at a document level. You can get to the attribute via javascript but the setting will take the 'last applied' value and apply at a per document level (not part of the document which is what you need) Maybe you could explain further what you are trying to achieve as there will almost certainly be a better and more enlightening way to achieve the same result you are after.
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
#11
|
|||
|
|||
|
Re: Javascript to change Base href?
it doesn't really matter actually, it wouldn't save that much code anyway, so someone can just close this, not important.
|
|
#12
|
||||
|
||||
|
Re: Javascript to change Base href?
Closed... as requested!
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
![]() |
| Tags |
| base, href, javascript |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| change the 'src' value using javascript | grglaz | JavaScript Forum | 5 | Jan 6th, 2008 21:50 |
| Javascript detect Flash, change CSS? | bigd | JavaScript Forum | 0 | May 3rd, 2007 08:20 |
| href and javascript | rksathishkhumar | JavaScript Forum | 4 | Nov 8th, 2006 13:13 |
| [SOLVED] How To: Change characters in a textarea? Using Javascript | Anonymous User | JavaScript Forum | 0 | Feb 16th, 2005 12:34 |
| how do u change the content of a <div> with javascript | benbacardi | JavaScript Forum | 4 | Jun 26th, 2004 19:14 |