473,385 Members | 1,944 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,385 software developers and data experts.

getAttribute("rel") has no properties

I'm having a hard time understanding an error that I'm getting. In the
code below, I'm trying to call substring() on an attribute of an
anchor. The error I get says "getAttribute("rel") has no properties"

The reason this confuses me is that getAttribute("rel") returns a
string, so it should have all the properties and methods of a string,
right?? What am I missing here?

- chris

var AnchorArray = document.getElementsByTagName("a");

for (var i = 0; i < AnchorArray.length; i++) {

if (AnchorArray[i].getAttribute("rel").substring(0,5) == "other")
alert("hi there");

}

Dec 8 '06 #1
2 5818
ch****************@gmail.com wrote :
I'm having a hard time understanding an error that I'm getting. In the
code below, I'm trying to call substring() on an attribute of an
anchor. The error I get says "getAttribute("rel") has no properties"

The reason this confuses me is that getAttribute("rel") returns a
string, so it should have all the properties and methods of a string,
right?? What am I missing here?

- chris

var AnchorArray = document.getElementsByTagName("a");

for (var i = 0; i < AnchorArray.length; i++) {

if (AnchorArray[i].getAttribute("rel").substring(0,5) == "other")
alert("hi there");

}
The error you get (getAttribure('rel') has no properties), means that
in thise case, getAttribute('rel') didn't return a string, but null,
or 'undefined'. None have any properties, hence the error message.

You may try using :
if (AnchorArray[i].hasAttribute('rel') && [...])
{
[...]
}

--
Naixn
http://fma-fr.net
Dec 9 '06 #2
naixn wrote:
if (AnchorArray[i].hasAttribute('rel') && [...])
that's it! thanks.

Dec 12 '06 #3

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

Similar topics

12
by: relaxedrob | last post by:
Hi All! I have a page with with the following style information: <link rel="stylesheet" type="text/css" href="/eEmployment/eTech.css" /> <style type="text/css"> DIV.Application {...
3
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to...
3
by: hutch | last post by:
Hi, I'm making use of this VERY useful function for a so called 'standards compliant' replacement for target="_blank": function externalLinks() { if (!document.getElementsByTagName) return;...
16
by: rodchar | last post by:
hey all, you know when you log in to msdn and go to subscription downloads, the header of the page is fixed and the body of the page scrolls, is that done with frames? thanks, rodchar
8
mikek12004
by: mikek12004 | last post by:
1) Script Title: Rich HTML Balloon Tooltip 2) Script URL :http://www.dynamicdrive.com/dynamicindex5/balloontooltip.htm 3) Problem Description: See this page General Music for links you can...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.