Solved

Many links with the same Target

Posted on 2003-11-10
6
159 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Printing a Google Form 2 25
Sums of coloumns in html/java 15 68
iframe detection of parent window scale 20 61
Centered Image 2 23
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now