473,654 Members | 3,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Overriding target attribute

1 New Member
First, a disclaimer: I am a librarian by trade, but have the responsibility of maintaining/updating our online catalog. I've dealt with some JavaScript before, but I am no expert, so please forgive my ignorance.

Question: Our automation system creates information dynamically for us. In one particular area of our page, it is adding a target=_self attribute that I believe is causing problems with our attempt at making a tab display. My theory is that if I can get this attribute changed to _blank, it might work, but I haven't figured out a way to do this. I have tried the following:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. / * Checks for target attribute in link tags. */
  3. var f=window.document.links;
  4. var i=f.length
  5. while(i--){
  6.      f[i].target='_blank'
  7. }
  8. </script>
  9.  
(the above was modified from another posting on this forum)

However, this does not seem to work because the link is still going to the _self target. Any suggestions would be greatly appreciated. Thank you!

Jamen McGranahan
Feb 13 '08 #1
1 1554
tswaters
19 New Member
please forgive my ignorance.
Forgiven!

Question: Our automation system creates information dynamically for us.
You're talking server-side scripting -- like ASP or PHP? Or is this more of like a batch program to roll up a database into static html files?

In one particular area of our page, it is adding a target=_self attribute that I believe is causing problems with our attempt at making a tab display.
Please elaborate on "tab display"

My theory is that if I can get this attribute changed to _blank, it might work,
target is generally used with framesets -- if you have multiple frames, setting the "target" on an anchor will make the link open up in that frame... _blank usually means new page, _top means at the top level, above all the frames ... and most anything else -- i think, not sure -- if not found, the browser will open a new window and reference it by that name.

"target" has been depricated in html4.01 strict.

but I haven't figured out a way to do this. I have tried the following:
Expand|Select|Wrap|Line Numbers
  1. / * Checks for target attribute in link tags. */
  2. var f=window.document.links;
  3. var i=f.length
  4. while(i--){
  5.      f[i].target='_blank'
  6. }
  7.  
*winces* -- that'll set 'em all... or raise an error... or something... try this:

[html]<body onLoad="messWit hAnchors( '_blank', '_self' )">[/html]
Expand|Select|Wrap|Line Numbers
  1. function messWithAnchors( _incomingTarget, _outgoingTarget ) {
  2.   var a = document.getElementsByTagName("A");
  3.   for(x=0;x<a.length;x++) {
  4.     if ( a[x].getAttribute( "target") == _incomingTarget ) {
  5.       a[x].setAttribute("target", _outgoingTarget );
  6.     }
  7.  
  8.     // test function to verify the target was set properly
  9.     // a[x].onclick = function() { alert(this.target); }
  10.   }
  11. }
  12.  
but anyway... back to my first question, if this is being generated automatically somehow, it would be WAY easier and more efficient to change the root source than it would be to wait for the document to load and change all the anchors' targets via javascript.
Feb 14 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1727
by: Dietmar Gräbner | last post by:
Hi Right now I'm dealing with derivation by restriction and I have some questions concerning the attribute property use in context of the derivation. Consider following Schema: <xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
24
2207
by: Mike | last post by:
Hello How do i get around target="_blank" is not allowed in xtml strict? Thanks Mike
16
12282
by: Mark van Ballegooijen | last post by:
When using the XHTML 1.0 validator at http://validator.w3.org/check, an error will be raised for every instance of a "target" attribute in "A" elements. Is it truely because it is not part of this specification anymore, or is it an error in the SGML parser ? Any alternatives ? html code : <a href="./page.html" class="pagelink" target="_self">some text</a> used doctype :
36
3958
by: randau | last post by:
I would like to use the Link Target attribute, but am inhibited by the likelihood of a newly opened browser window completely hiding the Parent browser window. Thus offering the illusion that you're still in the same browser, but the Back Button no longer works. I've done some experimentation and came up with the conclusion that Microsoft's IE browser has a relatively small likelihood of that happening, but that Netscape's browsers...
2
3599
by: ESPNSTI | last post by:
Hi, I'm very new to C# and .Net, I've been working with it for about a month. My experience has been mainly with Delphi 5 (not .Net). What I'm looking for is for a shortcut way to override a property without actually having to reimplement the get and set methods. In other words, override the the property without changing the functionality of the base property and without explicitly having to reimplement the get and set methods to make it do...
1
6914
by: Joe | last post by:
I have a web.sitemap file that has the url title and description. I then have this attac attached to a menu. I want some of my menu choices to open up in a page in a new window ie _blank as target. How do I do this with a web.sitemap file
4
1782
by: Raja Raman Sundararajan | last post by:
Hello guys, I have data stored in the database which has special characters like <, etc. Case 1: Whenever I wanted to present the output to a browser I need to escape these special characters into the browser equivalent like &lt; &gt; etc.( for example by using the cgi module) Case 2: Whenever I wanted to present the output to some client other than a browser, I wanted to present the data as it is stored in the database.
10
105177
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that make use of these methods assume that the methods obey these contracts so it is necessary to ensure that if your classes override these methods, they do so correctly. In this article I'll take a look at the equals and hashCode methods. ...
92
5127
by: Erwin Moller | last post by:
Hi group, I encoutered page validation error, but I don't know a way around. The page has the following doctype: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> Some hyperlinks need to open to a new window, so I used the (wrong) target="" attribute.
0
8372
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8285
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.