I found a solution, but this is not the best, so I'm still looking for a solution. See my answer for what I did.
UPDATE . My error persists as described below, but if I open IE Developer Tools, the error will disappear! If I close the browser and open the error again, it will appear again!
UPDATE 2 . I tried pasting the following code into my JS to make sure this solves the problem, and it doesnโt:
if (!("console" in window) || !("firebug" in console)) { var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; window.console = {}; for (var i = 0, len = names.length; i < len; ++i) { window.console[names[i]] = function(){}; } }
And then this:
var console = {}; console.log = function(){};
I also looked through my JS files and never came across a console.log function that would throw an error.
This is a difficult problem and I will do my best to explain. I set cookies on the page that will show the lightbox on the first visit. It works fine in FF, Chrome, etc., but not in IE.
What happens in IE is a script to call my lightboxes (colorbox), but all I see is an AJAX Loader hang, and the content never loads. I realized that the script shot too early. I used $j(document).ready(function() , I switched to: $j(window).load(function() , and everything seemed to be all right, and it worked correctly until I started with another page and did not go to the above page.
If I start from any other page and click on the link, I will have the same problem! The cookie works correctly and does not start the box a second time.
In other words, if I delete cookies and start from the problem page, then no problem. BUT, if I start from any other page (with cleared cookies) and go to the page above, the color package will not load properly.
From what I can say, $j(window).load(function() is not working properly.
I do not get errors from IE. I am using IE 8 for testing and cannot test 9 since I am using Windows XP. (I was told that it works fine in IE 9, but did not confirm this) the script is in the <head> my document. (If I moved the script to <body> , it completely broke the page.)
I read about DOCTYPE issues that aren't right or short term, and color issues in IE. My DOCTYPE is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
Any thoughts or ideas are welcome!
Here is my code that I use:
Javascript
var $j = jQuery.noConflict(); $j(window).load(function() { //window.onload = function() does not function properly either... if(!$j.cookie('gallerycookie')){ $j.colorbox({ inline:true, href:"#gallery-nav-instruct" }); $j.cookie("gallerycookie", 1, { expires: 30, path: '/' }); } });
HTML
<div style="display:none"> <div id="gallery-nav-instruct"> <h2>Gallery Navigation Instructions - Step 1</h2><h2 style="text-align:right"> <a style="text-align:right;" class="inline cw" href=" #gallery-enlarge-instruct">Step 2</a></h2> <p> </p> <p class="white"><img src="/Images/Pages/gallery-navigation.jpg" width="890" height="450" alt="Gallery Navigation Instructions" /></p> </div> </div> <div style="display:none"> <div id="gallery-enlarge-instruct"> <h2>Gallery Navigation Instructions - Step 2</h2> <p> </p> <h2><a class="inline cw" href="#gallery-nav-instruct">Step 1</a> </h2> <p class="white"><img src="/Images/Pages/gallery-enlarge.jpg" width="890" height="510" alt="Gallery -Enlarged View Instructions" /></p> </div> </div>
One more note: I am using jAlbum on the page and I do not see conflicts, but may be the problem? I cannot post this code here, since it will exceed the post-limit for SO.
To run this error from this page , a lightbox will appear. Click Message Examples (lower left corner of the light box or the first item in the menu without a light box).
Below is a direct link to the page. (Going to the page directly will not result in an error.)
I tried using window.onload = function() and this problem arose.
I tried using an event handler to run the script after loading the div, which did not run the script at all. here is this code:
var $j = jQuery.noConflict(); $j('#gallery-nav-instruct').load(function() { if(!$j.cookie('gallerycookie')){ $j.colorbox({ inline:true, href:"#gallery-nav-instruct" }); $j.cookie("gallerycookie", 1, { expires: 30, path: '/' }); } });