AntoniL
asked on
Many links with the same Target
Hi lads,
I've got, say, 2 links with the same target, such:
<a href="hello.htm#1" target="MyIFrame2">Bookmar k 1</a>
<a href="hello.htm#2" target="MyIFrame2">Bookmar k 2</a>
Now, is there any way I could use a CSS or whatever to specify that all these links have the same target?, I just want to get rid of the target="MyIFrame2" bit. I know it sounds stupid but I'm writing a 1MB HTML (with hundreds of links with the same target) page and trying to get rid of as much text as I can. To make things more difficult, I've got two frames, left & right, with an IFRAME on each page. The links you see above go into the first IFRAME, and try to bookmark on the second IFRAME. Is that clear?, hope so ...
Any ideas guys?, remember, trying to change target="MyIFrame2" to something like onclick="DoSomething()" and with javascript handle the call, wouldn't change the size of my HTML file since I'd have to replace target="MyIFrame2" with onclick="DoSomething()", for this reason I mentioned a CSS before ...
Thanks in advance
T
I've got, say, 2 links with the same target, such:
<a href="hello.htm#1" target="MyIFrame2">Bookmar
<a href="hello.htm#2" target="MyIFrame2">Bookmar
Now, is there any way I could use a CSS or whatever to specify that all these links have the same target?, I just want to get rid of the target="MyIFrame2" bit. I know it sounds stupid but I'm writing a 1MB HTML (with hundreds of links with the same target) page and trying to get rid of as much text as I can. To make things more difficult, I've got two frames, left & right, with an IFRAME on each page. The links you see above go into the first IFRAME, and try to bookmark on the second IFRAME. Is that clear?, hope so ...
Any ideas guys?, remember, trying to change target="MyIFrame2" to something like onclick="DoSomething()" and with javascript handle the call, wouldn't change the size of my HTML file since I'd have to replace target="MyIFrame2" with onclick="DoSomething()", for this reason I mentioned a CSS before ...
Thanks in advance
T
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Don't encourage them... ;-)
Unless, of course, you also tell them to add that 2.5 mb wav file as a background sound...
Unless, of course, you also tell them to add that 2.5 mb wav file as a background sound...
You could also use DOM to set the target property dynamically.
The exact script would depend on how your document is structured. For instance, if all the links to point to a particular target are in one section indicated by <div id="section1">...</div> then you can do this:
<script type="text/javascript">
window.onload = fixTargets;
function fixTargets()
{
var sectionOneDiv = document.getElementById("s ection1");
var sectionOneLinks = sectionOneDiv.getElementsB yTagName(" a");
for(var i = 0; i < sectionOneLinks.length; i++)
sectionOneLinks[i].target = "MyIFrame1";
}
</script>
This could be generalised for many sections of a document/many targets.
The exact script would depend on how your document is structured. For instance, if all the links to point to a particular target are in one section indicated by <div id="section1">...</div> then you can do this:
<script type="text/javascript">
window.onload = fixTargets;
function fixTargets()
{
var sectionOneDiv = document.getElementById("s
var sectionOneLinks = sectionOneDiv.getElementsB
for(var i = 0; i < sectionOneLinks.length; i++)
sectionOneLinks[i].target = "MyIFrame1";
}
</script>
This could be generalised for many sections of a document/many targets.
ASKER
Thanks Georgemarian, it did work. Thanks also to webwoman, got a tissue to wipe my tears off?
Cheers lads, see u around
T
Cheers lads, see u around
T
You're welcome - and here's to unlimited bandwidth :-)
Don't. Nobody will EVER look at it. The browser will probably time out before it completely loads. 1MB is WAY too big for one page. BREAK IT UP.
And seriously think about getting rid of the iframe.