Solved

Many links with the same Target

Posted on 2003-11-10
6
158 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
Comment Utility
>>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
Comment Utility
<html>
<head>
<title>Go grap a coffee or two</title>
<base target="MyIFrame2">
</head>
<body>
etc...
0
 
LVL 19

Expert Comment

by:webwoman
Comment Utility
Don't encourage them... ;-)

Unless, of course, you also tell them to add that 2.5 mb wav file as a background sound...
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 11

Expert Comment

by:Zontar
Comment Utility
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
Comment Utility
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
Comment Utility
You're welcome - and here's to unlimited bandwidth :-)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

744 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

13 Experts available now in Live!

Get 1:1 Help Now