Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,701
    Thanks
    6
    Thanked 1,011 Times in 984 Posts

    addLoadEvent, appendChild – IE 6

    OK, two problems in IE 6 (and in IE 6 only):

    I’m using addLoadEvent for my scripts and niceforms to enhance my form elements. As far as I’ve read addLoadEvent should add a new event without interfering with previously (or later) assigned onload events. This seems to fail in my case and while I could overcome the issue by changing niceforms’ window.onload event to an addLoadEvent function this doesn’t work in IE 6 and I have no idea why.

    It does work if I change the order in which the scripts are included in my documents (i. e. if I call niceforms.js before scripts.js). However, I can’t do that because niceforms is a little buggy in that it’s not flexible enough to calculate positions when elements are removed from the DOM or hidden after niceforms has been initalized which I do on http://vipstephan.de/temp/buchfinder.htm, so I have to call scripts.js befaore niceforms.js. What’s the problem and how can I solve it?

    The second thing is a minor issue but I also don’t get it. If you examine scripts.js you’ll see that I add a print button to the pages but IE 6 gives me the error: “'text' is undefined”. Why is that? I’ve defined 'text' a few lines above.

    Any help is greatly appeciated.
    Last edited by VIPStephan; 05-05-2012 at 12:28 AM. Reason: Removed/changed invalid links

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,701
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    OK, well, I was able to “fix” the first issue because I’m using mootools for some more effects and the DOMReady function isn’t interfering with the onload event of niceforms anymore.

    However, I still don’t know why IE 6 won’t append the text I’ve defined before. Just in case you’re too lazy to look at the files here’s the simple function:
    Code:
    	var druck = document.createElement('a');
    	druck.setAttribute('id','drucken');
    	druck.setAttribute('href',''); // IE braucht href-Attribut, um CSS :hover zu unterstützen
    	var text = document.createTextNode('Seite drucken');
    	druck.appendChild(text);
    	document.getElementById('kopf').appendChild(druck);
    	druck.onclick = function() {window.print();}
    It says 'text' is undefined.

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,701
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    Hm, it’s very strange… I’ve created a simple testing file and there I could append the element(s) correctly. So then I recreated the original HTML file step by step and created a new JS file, copying the JS from the old JS file step by step as well and then it worked as if it had always been like that. It seems like IE didn’t like the JS file being called scripts.js because the new one has a different name and it works.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •