Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Problem with a Javascript in Internet Explorer when Lightbox is on the same page...

  1. #1
    Join Date
    Jan 2008
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with a Javascript in Internet Explorer when Lightbox is on the same page...

    1) Script Title:
    Lightbox image viewer 2.03a

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...box2/index.htm

    3) Describe problem:

    I have a page were I won't to use Lightbox together with Tab Content Script.
    Because I don't have the possibility to work around in all the code (it's a system with locked code) I have to use a Javascript so I can change some words on all places at the same time.
    That script is in the quote:
    setTimeout("Init()", 1)

    function Init() {
    var arrTxt=new Array("Beskrivning","Specifikationer","Dokument, lšnkar...");
    var arrObj=new Array("t1t","t2t","t3t");
    for(i in arrTxt){
    document.getElementById(arrObj[i]).innerHTML=arrTxt[i];
    }
    }
    The problem is that it don't work in Internet Explorer. It works fine in Firefox.
    If I delete the prototype.js in Lightbox it also works in Internet Explorer. So it's something in Lightbox/prototype.js that is incompatible with my quoted script when used in IE.
    The question is what?

    Here is a link to a zip-archive with the files and images
    http://www.megaupload.com/?d=6PF39O6R

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You may have better luck doing it this way:

    Code:
    function Initstuff() {
    var arrTxt=new Array("Beskrivning","Specifikationer","Dokument, lšnkar...");
    var arrObj=new Array("t1t","t2t","t3t");
    for(var i=1;i<arrTxt.length;++i)
    if(document.getElementById(arrObj[i])&&arrTxt[i])
    document.getElementById(arrObj[i]).innerHTML=arrTxt[i];
    }
    
    setTimeout("Initstuff()", 1)
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2008
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    You may have better luck doing it this way:

    Code:
    function Initstuff() {
    var arrTxt=new Array("Beskrivning","Specifikationer","Dokument, lšnkar...");
    var arrObj=new Array("t1t","t2t","t3t");
    for(var i=1;i<arrTxt.length;++i)
    if(document.getElementById(arrObj[i])&&arrTxt[i])
    document.getElementById(arrObj[i]).innerHTML=arrTxt[i];
    }
    
    setTimeout("Initstuff()", 1)
    No, that one do so the "t1t" won't be seen in Firefox either.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Works here with your demo download, but this is even better:

    Code:
    function Initstuff() {
    var arrTxt=new Array("Beskrivning","Specifikationer","Dokument, lšnkar...");
    var arrObj=new Array("t1t","t2t","t3t");
    for(var i=1;i<arrTxt.length;++i)
    if(document.getElementById(arrObj[i])&&arrTxt[i])
    document.getElementById(arrObj[i]).innerHTML=arrTxt[i];
    }
    
    window.onload=Initstuff;
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jan 2008
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Works here with your demo download, but this is even better:

    Code:
    function Initstuff() {
    var arrTxt=new Array("Beskrivning","Specifikationer","Dokument, lšnkar...");
    var arrObj=new Array("t1t","t2t","t3t");
    for(var i=1;i<arrTxt.length;++i)
    if(document.getElementById(arrObj[i])&&arrTxt[i])
    document.getElementById(arrObj[i]).innerHTML=arrTxt[i];
    }
    
    window.onload=Initstuff;
    Hmm, I can't get it to work properly.
    I include a print screen so you can see how it looks like on my screen.
    I'm missing text on the first tab, both with and without active and hover.
    But it's a progress from before when it was totally blank in IE...

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Here's the archive I downloaded rezipped. The only changes are its name, the name of its root folder, the removal of the two largest images, and the modifications to the ers.js file:

    Attachment 1596
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jan 2008
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, I've missed to get rid of a link to a backgroundpic in tabcontent.css that I've used instead of the Javascript to show text on the tabs.
    After I have adjusted that I think you will se that the first tab is missing text.

    Se my attachment below:

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    function Initstuff() {
    var arrTxt=new Array("Beskrivning","Specifikationer","Dokument, lšnkar...");
    var arrObj=new Array("t1t","t2t","t3t");
    for(var i=0;i<arrTxt.length;++i)
    if(document.getElementById(arrObj[i])&&arrTxt[i])
    document.getElementById(arrObj[i]).innerHTML=arrTxt[i];
    }
    
    window.onload=Initstuff;
    Works. But, if you want to preserve the divisions, use:

    var arrObj=new Array("t1d","t2d","t3d");

    instead of:

    var arrObj=new Array("t1t","t2t","t3t");
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Jan 2008
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Code:
    function Initstuff() {
    var arrTxt=new Array("Beskrivning","Specifikationer","Dokument, lšnkar...");
    var arrObj=new Array("t1t","t2t","t3t");
    for(var i=0;i<arrTxt.length;++i)
    if(document.getElementById(arrObj[i])&&arrTxt[i])
    document.getElementById(arrObj[i]).innerHTML=arrTxt[i];
    }
    
    window.onload=Initstuff;
    Works. But, if you want to preserve the divisions, use:

    var arrObj=new Array("t1d","t2d","t3d");

    instead of:

    var arrObj=new Array("t1t","t2t","t3t");
    Thank you very much for your patience ... ... but I wonder if we are looking at the same code.

    1.)
    If I use this in ers.js I got the result I presented above (in the included image-file) in Firefox and with Internet Explorer after security warnings. If I publish it on the net it doesn't work at all in IE:
    function Initstuff() {
    var arrTxt=new Array("Beskrivning","Specifikationer","Dokument, lšnkar...");
    var arrObj=new Array("t1t","t2t","t3t");
    for(var i=1;i<arrTxt.length;++i)
    if(document.getElementById(arrObj[i])&&arrTxt[i])
    document.getElementById(arrObj[i]).innerHTML=arrTxt[i];
    }

    setTimeout("Initstuff()", 1)
    2.)
    If I use this instead I got all tabs with text in Firefox, but it don't work in Internet Explorer:
    function Init() {
    var arrTxt=new Array("Beskrivning","Specifikationer","Dokument, lšnkar...");
    var arrObj=new Array("t1t","t2t","t3t");
    for(i in arrTxt){
    document.getElementById(arrObj[i]).innerHTML=arrTxt[i];
    }
    }

    setTimeout("Init()", 1)
    3.) Now, if we take the 2.) - code and also take away the link in index.html to prototype.js it also work in Internet Explorer *yes*. I do have a warning triangel down in left corner. But it works...

    The question is what. It's the same if I use setTimeout or window.onload.

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The code I am looking at is the code I downloaded from the link you provided. It is the same as the code I made available in my attached zip post. The setTimeout is a bad idea. It assumes that the elements required by the script will be ready at an arbitrary point 1 millisecond after the setTimeout is called. Also, the for(i in arrTxt){ is a bad idea. There could be other i in arrTxt than just its array items, and i is in the global scope, so may not be empty at the beginning of the loop.

    What version(s) of IE are you using? If you have a live page that demonstrates the problem, please provide a link to it.

    Also, from your last post, it looks like you haven't updated this line:

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

    as indicated in my previous post - though this shouldn't have anything to do with an error, just to do with what elements get updated.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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