Solved

Many links with the same Target

Posted on 2003-11-10
6
163 Views
Last Modified: 2010-04-09
Hi lads,
I've got, say, 2 links with the same target, such:

<a href="hello.htm#1" target="MyIFrame2">Bookmark 1</a>
<a href="hello.htm#2" target="MyIFrame2">Bookmark 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
0
Comment
Question by:AntoniL
6 Comments
 
LVL 19

Expert Comment

by:webwoman
ID: 9717799
>>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.

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.
0
 
LVL 31

Accepted Solution

by:
seanpowell earned 50 total points
ID: 9717954
<html>
<head>
<title>Go grap a coffee or two</title>
<base target="MyIFrame2">
</head>
<body>
etc...
0
 
LVL 19

Expert Comment

by:webwoman
ID: 9718965
Don't encourage them... ;-)

Unless, of course, you also tell them to add that 2.5 mb wav file as a background sound...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:Zontar
ID: 9720237
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("section1");
  var sectionOneLinks = sectionOneDiv.getElementsByTagName("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.
0
 

Author Comment

by:AntoniL
ID: 9720766
Thanks Georgemarian, it did work. Thanks also to webwoman, got a tissue to wipe my tears off?
Cheers lads, see u around

T
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 9720974
You're welcome - and here's to unlimited bandwidth :-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question