473,387 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

address LINK object in the HEAD section

VK
Having HEAD section like that:

<head>

<title>Foo</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">

<link
title="linkObject"
rel="Alternate Appendix"
type="text/plain"
href="data.txt"
charset="iso-8859-1"
hreflang="en-US">

</head>

what would be the most realible way to get "linkObject" reference?

var roof = document.getElementsByTagName('HEAD')[0];
// ?

Dec 20 '05 #1
5 2777
VK wrote:
Having HEAD section like that:

<head>

<title>Foo</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">

<link
title="linkObject"
rel="Alternate Appendix"
type="text/plain"
href="data.txt"
charset="iso-8859-1"
hreflang="en-US">

</head>

what would be the most realible way to get "linkObject" reference?

var roof = document.getElementsByTagName('HEAD')[0];
// ?


Replacing `title=' with `id=' and using Document::getElementById().
PointedEars
Dec 20 '05 #2
VK

Thomas 'PointedEars' Lahn wrote:
Replacing `title=' with `id=' and using Document::getElementById().


Are ID's formally allowed for LINK? Or for other elements in the
non-rendering section (HEAD) I did not find this attribute listed
neither in W3C nor in MSDN. From the other side TITLE is required by
W3C for alternate content links.

Not to say I technically care too much but for some reasons I want to
have this LINK usage free of any "hacking model" accusations. Unusual -
yes, but fully standard compliant.

Dec 21 '05 #3
VK wrote:
Thomas 'PointedEars' Lahn wrote:
Replacing `title=' with `id=' and using Document::getElementById().
Are ID's formally allowed for LINK? Or for other elements in the
non-rendering section (HEAD) I did not find this attribute listed
neither in W3C nor in MSDN.


You must have a different "W3C" and "MSDN" than I have ;-)

The `id' attribute is allowed for "All elements but BASE,
HEAD, HTML, META, SCRIPT, STYLE, TITLE".
See <URL:http://www.w3.org/TR/html4/index/attributes.html>

,-<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/id.asp>
|
| Applies To
| [...] LABEL, LEGEND, LI, LINK, LISTING, [...]
^^^^
The (X)HTML DTDs clearly state the `link' element has the `id' attribute:

<URL:http://www.w3.org/TR/REC-html32#link>

<http://www.w3.org/TR/html4/struct/links.html#edef-LINK>
(note the `%attrs;' entity reference and follow the links
<URL:http://www.w3.org/TR/html4/sgml/dtd.html#attrs>
<URL:http://www.w3.org/TR/html4/sgml/dtd.html#coreattrs>)

<URL:https://www.cs.tcd.ie/15445/15445.html#DTD>
(search for "ATTLIST link")

<URL:http://www.w3.org/TR/xhtml1/dtds.html#dtdentry_xhtml1-strict.dtd_link>
(search for "ATTLIST link", note the `%attrs;' entity reference and follow
the links)

The `title' attribute, however, should provide for a short description of
the element.

<URL:http://www.w3.org/TR/html4/struct/global.html#adef-title>
From the other side TITLE is required by W3C for alternate content links.
How do you got that idea?

<URL:http://www.w3.org/TR/html4/struct/links.html#h-12.3.3>
Not to say I technically care too much
But you should, for your own sake and that of users of your content.
but for some reasons I want to have this LINK usage free of any "hacking
model" accusations. Unusual - yes, but fully standard compliant.


Accessing the `id' attribute value is sufficiently un"hack"ish :)
PointedEars
Dec 21 '05 #4
function getElementByAttribute(tagn,attrib,str){
var A=document.getElementsByTagName(tagn);
var O;
var L=A.length;
for(var i=0;i<L;i++){
var tem=A[i];
if(tem.getAttribute(attrib)&& tem.getAttribute(attrib)==str){
O=tem;
break;
}
}
return O;
}
Dec 21 '05 #5
function getElementsByAttribute(tagn,attrib,str){
var A=document.getElementsByTagName(tagn);
var O=new Array();;
var L=A.length;
for(var i=0;i<L;i++){
var tem=A[i];
if(tem.getAttribute(attrib)){
if(str) tem.getAttribute(attrib)==str) O.push(tem);
else O.push(tem);
}
return O;
}
// In your case you can call: getElementsByAttribute('link','title',str)
(str is whatever you want to match)
Dec 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: VK | last post by:
I have this code failing to work in IE: getElementsByTagName doesn't return elements from my JS namespace. What's wrong? <html xmlns:js> <head> <title>Que</title> <meta...
16
by: Shwetabh | last post by:
Hi, This is a question asked to me in an interview. I haven't been able to figure out an answer for it. Please try to see what can be done about the following problem. /* I have been given two...
4
by: Sergey Morkovkin | last post by:
Hi, guys! Does anyone knows the resolution of a problem when i need to insert <link> or <script> tag into HEAD section dynamically? I was trying few ways to do this: 1) RegisterClientScriptBlock...
3
by: Dave | last post by:
Is there a way to dynamically add a reference to the css stylesheet from the codebehind similarly to the script registration features? I was thinking of adding this code to a base class and...
4
by: usenet | last post by:
Hello, I am running my code on an embedded platform without OS. I have defined some data in a section called .eeprom. The section is defined by the linker script and starts at address zero. The...
9
by: Viken Karaguesian | last post by:
Hello all, I'm making a calendar section in a website. Each month is its own page and navigated by Previous / Next links. I have it working now with standard hyperlinks, but I want to learn how...
4
by: Mike | last post by:
Hi all, In my recent ASP.NET 2.0 appl, I need to verify that the supplied email address is valid or not. So, here's my situation: - In my <profilearea, I created <isVerifiedproperty. - Suppose a...
2
by: =?Utf-8?B?amVmZjMxMTYy?= | last post by:
Hi all Is there a way to add a LINK rel="stylesheet" href="StyleSheet1.css" type="text/css" tag to the header of each page at run time, rather than having to copy and paste it into the html view...
26
by: Nospam | last post by:
I am trying to open a link in a new template window : <a onclick="windowopen('example.html','example');return false;" href="http://www.example.com" target="_blank"example link</a> such that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.