473,404 Members | 2,170 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,404 software developers and data experts.

Address elements from custom namespace in IE

VK
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 http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

<style type="text/css">
<!--
body { background-color: #FFFFFF}
@media all {
js\:link { font-style: italic; color: #0000FF; text-decoration:
underline; cursor: hand; cursor: pointer}
}
-->
</style>

<script type="text/javascript">
<!--
function normalizeLinks(){
var jsLink = document.getElementsByTagName('JS:LINK');
// The method above doesn't work with IE
// IE has some fancy twist I have to be reminded again
for (i=0; i<jsLink.length; i++) {
jsLink[i].title = '';
jsLink[i].style.fontStyle = 'normal';
}
}

if ('addEventListener' in self) {
self.addEventListener('load',normalizeLinks,false) ;
}
else {
self.attachEvent('onload',normalizeLinks);
}
//-->
</script>

</head>

<body>

<p>
<a href="http://www.mozilla.org/products/firefox/">Mozilla Firefox</a>
</p>

<p>
<js:link title="JavaScript function call..."
onclick="alert('Booh!')">JavaScript call 1</js:link>
</p>

<p>
<a href="http://www.microsoft.com/windows/ie/default.mspx">Microsoft
Internet Explorer</a>
</p>

<p>
<js:link title="JavaScript function call..." onclick="alert('Booh
again!')">JavaScript call 2</js:link>
</p>

<p>
<a href="http://browser.netscape.com/ns8/">Netscape Navigator</a>
</p>

<p>
<js:link title="JavaScript function call..." onclick="alert('Booh
again!')">JavaScript call 3</js:link>
</p>
</body>
</html>

Oct 26 '05 #1
4 2506


VK wrote:
I have this code failing to work in IE: getElementsByTagName doesn't
return elements from my JS namespace. What's wrong?
<html xmlns:js> var jsLink = document.getElementsByTagName('JS:LINK');
// The method above doesn't work with IE <js:link title="JavaScript function call..."
onclick="alert('Booh!')">JavaScript call 1</js:link>


Does it help if you use an <?IMPORT> processing instruction
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/pi/import.asp>
to bind that prefix?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 26 '05 #2

VK wrote:
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 http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

<style type="text/css">
<!--
body { background-color: #FFFFFF}
@media all {
js\:link { font-style: italic; color: #0000FF; text-decoration:
underline; cursor: hand; cursor: pointer}
}
-->
</style>

<script type="text/javascript">
<!--
function normalizeLinks(){
var jsLink = document.getElementsByTagName('JS:LINK');
// The method above doesn't work with IE
// IE has some fancy twist I have to be reminded again
for (i=0; i<jsLink.length; i++) {
jsLink[i].title = '';
jsLink[i].style.fontStyle = 'normal';
}
}

if ('addEventListener' in self) {
self.addEventListener('load',normalizeLinks,false) ;
}
else {
self.attachEvent('onload',normalizeLinks);
}
//-->
</script>

</head>

<body>

<p>
<a href="http://www.mozilla.org/products/firefox/">Mozilla Firefox</a>
</p>

<p>
<js:link title="JavaScript function call..."
onclick="alert('Booh!')">JavaScript call 1</js:link>
</p>

<p>
<a href="http://www.microsoft.com/windows/ie/default.mspx">Microsoft
Internet Explorer</a>
</p>

<p>
<js:link title="JavaScript function call..." onclick="alert('Booh
again!')">JavaScript call 2</js:link>
</p>

<p>
<a href="http://browser.netscape.com/ns8/">Netscape Navigator</a>
</p>

<p>
<js:link title="JavaScript function call..." onclick="alert('Booh
again!')">JavaScript call 3</js:link>
</p>
</body>
</html>


Just from a quick test, there is a DOM Level 2 method,
getElementsByTagNameNS(String namespaceURI, String localName). However,
this method is available in Firefox and not in IE. But, IE does have a
namespace collection, document.namespaces, in which you can iterate
through.

Oct 26 '05 #3
VK
Martin Honnen wrote:
Does it help if you use an <?IMPORT> processing instruction
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dh...>
to bind that prefix?
<?IMPORT...> seems useless w/o "implementation" attribute pointing to a
behavior source you want to import from. Anyway I tried <?IMPORT
namespace="js"> with no progress.
web.dev wrote: IE does have a namespace collection, document.namespaces,
in which you can iterate through.


The only (and above it not documented) property of "namespace" related
to the internal content appeared to be "tagNames".
So this object seems to be for global namespace management
(switching/adding). Any way I tried to use
document.namespaces[i].tagNames which leads immediately to the script
error "Not implemented".

This error combined with Martin Honnen's tip may mean that you can
display but you cannot handle custom elements in IE w/o corresponding
DTD file properly written and included?

Something like:
<!DOCTYPE HTML PUBLIC "-//VK//DTD HTML X.XX//EN"
"http://www.geocities.com/schools_ring/js.dtd">
(The above is a joke and I *really* hope it will remain such).

This IE is a real Pandora box but we have to eat it somehow... But how?

Oct 26 '05 #4

VK wrote:
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 http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

<style type="text/css">
<!--
body { background-color: #FFFFFF}
@media all {
js\:link { font-style: italic; color: #0000FF; text-decoration:
underline; cursor: hand; cursor: pointer}
}
-->
</style>

<script type="text/javascript">
<!--
function normalizeLinks(){
var jsLink = document.getElementsByTagName('JS:LINK');
// The method above doesn't work with IE
// IE has some fancy twist I have to be reminded again
for (i=0; i<jsLink.length; i++) {
jsLink[i].title = '';
jsLink[i].style.fontStyle = 'normal';
}
}

if ('addEventListener' in self) {
self.addEventListener('load',normalizeLinks,false) ;
}
else {
self.attachEvent('onload',normalizeLinks);
}
//-->
</script>

</head>

<body>

<p>
<a href="http://www.mozilla.org/products/firefox/">Mozilla Firefox</a>
</p>

<p>
<js:link title="JavaScript function call..."
onclick="alert('Booh!')">JavaScript call 1</js:link>
</p>

<p>
<a href="http://www.microsoft.com/windows/ie/default.mspx">Microsoft
Internet Explorer</a>
</p>

<p>
<js:link title="JavaScript function call..." onclick="alert('Booh
again!')">JavaScript call 2</js:link>
</p>

<p>
<a href="http://browser.netscape.com/ns8/">Netscape Navigator</a>
</p>

<p>
<js:link title="JavaScript function call..." onclick="alert('Booh
again!')">JavaScript call 3</js:link>
</p>
</body>
</html>


For IE specific solutions, I suggest that you delve more deeply into
the MSDN web site, and experiment a little:-

Two aspects which may help are:-

1. You can still use getElementsById("link").

This will return all "link" elements from all namespaces in the
document. As long as the local (i.e. RHS name) name is unique to a
given namespace (which I admit rather defeats the object of a
namespace), it can achieve what you are looking for.

2. If you need to filter the collection of "link" elements returned,
then you can use the "scopeName" property, introduced from IE5, which
will return the the namespace (i.e. LHS name) - namely "js".

Julian

Oct 27 '05 #5

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

Similar topics

0
by: C. M. Sperberg-McQueen | last post by:
wooks (wookiz@hotmail.com) wrote: > <?xml version='1.0'?> > <userlogin xmlns="urn:faster:userlogin" > xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> > <login>mick</login> > ...
8
by: Hugh Sparks | last post by:
When processing an xml document that contains elements such as: <element xmlns="goop"/> ... <element xmlns="gleep"/> I want to create two xsl stylesheet templates: one that matches the...
9
by: david wolf | last post by:
I want to delete all even numbers in a vector, I am not sure if there's any better way to do it. Following program is how I did it. Look at the part of code beginning from comments: //delete all...
3
by: __PPS__ | last post by:
Hello, I'm newbe to xml/dtd (and probably I don't use all the termins correctly). I'm writing an application that parses xhtml file with custom elements and splits it into 2 parts - valid xhtml1.0...
1
by: Jon Stranger | last post by:
I am trying to build a custom web control based on DataGrid using VS.NET Standard Edition and have a problem referencing the Columns collection. The control has been built in a separate VS.NET...
4
by: Matt Jensen | last post by:
Howdy Relatively new to .NET, I'm trying to create custom a namespace for use in creating some utility classes, which I seem to have done OK, however, I'm having a problem trying to use the class...
1
by: Hani Atassi | last post by:
I am trying to add a resource file (resx) to my project in VB.NET. The namespace of the file is always equal to (RootNameSpace) of the project. This is even if I set the value "Custom Tool...
0
by: jts2077 | last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as: <store ...
10
by: cykill | last post by:
Hi. I'm new to asp.net and I've been searching on the net and in book on how to use custom namespace. I've created my own custom namespace and I just need a straight answer on where to put the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.