473,789 Members | 2,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript, Firefox and document.links

He there!
I've discovered that the

=============== =============== =============== ====
document.links( 'link_id_here') .href = "something" ;
=============== =============== =============== ====

is not applicable for the Firefox (even for the 1.0.6), and I'm falling
into passing through the array and checking each link id.

Could anybody confirm it's true and/or direct to a more elegant
solution if any?
Thanx,
Andrew

Aug 31 '05
10 5394
> But, all my question is based on a createElement
and setting its (new) attributes on the fly
Ah, I misunderstood (because OP was only about changig given elements).
where (setting attributes to a virtual element) :
- my IE fall down, errores, breaks, if type it's tried to set
whatever I can test
By newly generated elements, you should of course being able to set the
Attribute by setAttribute("t ype", "inputtype" ) - but changing the attribute this
way is without effect. So the type can be given once and is then only readable.
So that's really a bug in your IE (and the IEs Mac-Version is famous for its
bugs, especially in JS :o(
- my IE wants 'className' as attribute for new class
while my FF wants 'class' for same attribute

All was in my comemted example I give here back :

example :

<html>
<script type="text/javascript">
var ind = 0;
function newTextField(id ) {
ind++;
var ntf = document.create Element('INPUT' );
ntf.setAttribut e('className',' inpText'); // IE way
ntf.setAttribut e('class','inpT ext'); // FF way
Didn't thought about the easiest way: Setting both attributes doesn't hurt the
other browsers, everyone can use the attribute he likes :)
ntf.id = id+ind; // don't know if ID is an attribute ?
Yes it is an attribute, ntf.setAttribut e('id',id+ind) should bring the same
resultat.
ntf.setAttribut e('type','text' ); // IE breaks function here
ntf.type = 'text'; // all as with this way

var val = 'new field id = '+id+ind;
ntf.setAttribut e('value',val);
var place = document.create Element('P');
place.appendChi ld(ntf);
document.body.a ppendChild(plac e);
}
</script>
<style type="text/css">
..inpText { background:yell ow; border:2px solid red; color:blue }
CSS-Classes should start with one dot:

..inpText { background:yell ow; border:2px solid red; color:blue }

IE accepts this, FF does not.
</style>
<button onclick="newTex tField('nouv'); ">New Field</button>
</html>

I try to tell to that new input element (createElement)
it's attribute would be one of types :
- text
- checkbox
- radio
- button
- submit
- reset
If I (and you, and they, we) can't set this type,
how to do to get some more radio-buttons, or check-boxes, or ... ?
OK, as said before, I misunderstood the problem. On creating the element, you're
able to set the type-attribute but it's not changeable.
[className]
this attribute is not understood by FF ... !

And that seems to be an error in the FF-Implemantation.


....
if (document.getEl ementById(eleme ntid).getAttrib ute("className" )) {
// use setAttribute("c lassName", "")

No, I am still in createElement
I can't get an attribute not yet set ...


Well, the same here: Other problem, so i described the wrong way. But simply
setting both, class AND className, as you did, seems to work fine.
document.getEle mentById(elemen tid).className = "green";

works in both browsers, IE and FF,

Yes, this way all work fine
document.getEle mentById(elemen tid).class = "green";

works in none, so FF seems to be a little bit inconsequent.

It seems to :-/


So IE5/mac has a bug in setting the Type-Attribute by setAttribute, so you have
to get around this bug by using another way, ie ntf.type = "".

On Windows, the posted code with setAttribute("t ype", "text") works fine in IE6
and after correcting the .. in the css in FF too.

I've still one last alternative, a little more code, but when generating new
elements the "cleaner" version: Does createElement work in IE/Mac?

var ntftype = document.create Attribute("type ");
ntftype.nodeVal ue = "text";
ntf.setAttribut eNode(ntftype);

Greetings

Martin
Sep 1 '05 #11

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

Similar topics

12
1949
by: Howard Kaikow | last post by:
Yesterday, I decided to try Firefox. I've encountered a behavior that is either a bug in Firefox or a bug in my Javascript code. I'll try to explain the problem, hoping that this newsgroup can (in)validate my Javascript code. First, I'll describe the purpose of the Javascript code. I often have a need to post a URL to something at my own web site, e.g., http://www.standards.com/Sorting/SortPerformanceComparison-Description.html. It is...
4
1973
by: DanielEKFA | last post by:
Hey hey :) Having a lot of problems with this. I'm helping my brother out with this art school web page. He has a big wish to have random images from the web shown in the background, and asked me to help him out. My idea is this: Use the CNN Top Stories RSS feed to harvest keywords, then use a random keyword from this harvest to search Google, get links from the result, look through random links here and get links to images, then load...
2
1744
by: Radu Ciurlea | last post by:
Hello. I want to make the browser show some suggestions under a text box (like the To: field in webmail interfaces that displays addresses in the addressbook). Basically whenever something changes in the text box (i.e. an onKeyUp even occurs) I check to see what words in the "address book" match the word in the box. After that I fill a <div> with links that onClick update the text box contents. Here's how it's written: in search.html:
9
2125
by: Astra | last post by:
Hi everybody Wonder if you could help me out. I created a simple JavaScript routine to enable a user to click backwards and forwards between small news articles. This routine works fine in IE and Safari, but in the latest FireFox I get no title or article, but do see the prev and next links and the article number. My HTML and JS simple routine is as follows:
8
3677
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
1
1903
by: Rabel | last post by:
Hi I am updating some pages from a website that is a few years old and I didnt work on the site then, but the javascript works in ie but not in firefox. The scripting is function yyLayerScroll(daTarget, delay, ex, ey, dx, dy, sx, sy, daT, daLoop, daFirst ) { var yyX; var yyY; var target = MM_findObj(daTarget); if(!target.oritop){ target.oritop = (document.layers)?target.top:target.style.top; target.orileft =...
12
2618
by: tim | last post by:
I am using foldoutmenu 3 and am having problems with viewing my menus in firefox. On my sub3 menus i have more than one line of text in some places. firefox does not recognise that there is more than one line and the text simply overlaps the sub-menus below it. I thought i had got around this by placing empty 'spacers' like so; oFoldMenu.make('sub3','')//spacer unfortunately, i have just viewed the site in IExplorer and it has added...
6
5834
by: scotty | last post by:
I have a script that loops through an existing table list and prepares each href element node to trigger a function when an image is clicked. The function that will be run passes a property value to the function upon clicking. The property value is one of the attributes defined for each respective href in the property list. In IE and Netscape, the property values pass correctly, but in Firefox, only the last property value in the list...
1
3672
by: dev08820 | last post by:
I have a javascript function that disables the hrefs on a page by assigning "#" to each href. Th eneed to do so is to disable links in a print preview window. The print preview window contains only page content and not navigation, etc. This works fine in IE6 but not in FireFox 2.0.0.2. In Firefox, the link always contains the current context or location. If a "#" is assigned the href becomes http://www.foo.com/context/currentpage.htm# instead...
0
9511
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
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10142
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
9021
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...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5422
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3703
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.