Weird JavaScript / IE bug

1) Go to -> all good.

2) Now, click on any of the menu items (Apartments for example) -> at the bottom of IE in the status bar, you will get a JavaScript error warning ("Object expected" if you look at the details).

3) Now, reload the page -> warning is gone. What the hell?

The error is generated by a JavaScript file which corresponds to the pull-down menu one can see when hovering over the "Our offers" menu item. The weird thing is that this does not happen when testing on my development machine under Windows, but appears on the production site running Linux. Note that this does not prevent the actual menu from working correctly, but it is annoying to see that warning and very weird to see it gone by simply reloading the page...

The JavaScript file in question is actually a '.phpjs' file which gets parsed by PHP to dynamically generate teh appropriate real estate vategories in the pull-down, based on what is in the database. Apache is correctly configured to let PHP parse .phpjs files (AddType application/x-httpd-php .php .php3 .phpjs) and to not apply gzip compression (mod_gzip_item_exclude file \.phpjs$). I have banged my head trying to solve this for hours, without any luck. Any help from someone having had a similar problem is welcome. Below is the code (core JS files are called by this but are part of AllWebMenus standard core files). Many thanks in advance.

require "../";
if (!$_SESSION['file_path']) {
require $cfg['pwd_file_path'];
require $cfg['lib_dir_path']."/database/";
require $cfg['lib_dir_path']."/html_elements/dialog/";
require $cfg['lib_dir_path']."/html_elements/output/";
require $cfg['lib_dir_path']."/application/";
$cx_prob=p_connect(); if ($cx_prob) { show_msg($cx_prob,"main"); exit; }
$sw_prob=switch_db($cfg['DBName']); if ($sw_prob) { show_msg($sw_prob,"main"); exit; }
//----------DHTML Menu Created using AllWebMenus PRO ver 3.1-#518---------------
var awmMenuName='ASJMenuEN';
var awmLibraryPath='/awmData-ASJMenuEN';
var awmImagesPath='/awmData-ASJMenuEN';
var awmSupported=(navigator.appName + navigator.appVersion.substring(0,1)=="Netscape5" || document.all || document.layers || navigator.userAgent.indexOf('Opera')>-1)?1:0;
if (awmAltUrl!='' && !awmSupported) window.location.replace(awmAltUrl);
if (awmSupported){
var awmMenuPath;
if (document.all) mpi=document.all['awmMenuPathImg-ASJMenuEN'].src;
if (document.layers) mpi=document.images['awmMenuPathImg-ASJMenuEN'].src;
if (navigator.appName + navigator.appVersion.substring(0,1)=="Netscape5" || navigator.userAgent.indexOf('Opera')>-1) mpi=document.getElementById('awmMenuPathImg-ASJMenuEN').src;
while ("'")>-1) {awmMenuPath=awmMenuPath.replace("'", "&#39;");}
var nua=navigator.userAgent,scriptNo=(nua.indexOf('Safari')>-1)?7:(nua.indexOf('Gecko')>-1)?2:((document.layers)?3:((nua.indexOf('Opera')>-1)?4:((nua.indexOf('Mac')>-1)?5:((nua.indexOf('Konqueror')>-1)?6:1))));
document.write("<SCRIPT SRC='"+awmMenuPath+awmLibraryPath+"/awmlib"+scriptNo+".js'><\/SCRIPT>");
var n=null;

var awmSubmenusFrame='';
var awmSubmenusFrameOffset;
var awmOptimize=1;
function awmBuildMenu(){
if (awmSupported){
awmCreateCSS(1,2,1,'#FFFFFF','#0055E5',n,'14px sans-serif',n,'none',0,n,0,4);
awmCreateCSS(1,2,1,'#000000','#FFFFFF',n,'14px sans-serif',n,'none',1,n,0,1);
awmCreateCSS(0,2,1,'#FFFFFF','#7A96DF',n,'14px sans-serif',n,'none',1,n,0,1);
awmCreateCSS(1,2,1,'#FFFFFF','#0055E5',n,'14px sans-serif',n,'none',2,n,0,0);
awmCreateCSS(1,2,0,'#000000','#B9CEFF',n,'12px Arial',n,'none',0,n,4,1);
awmCreateCSS(0,2,0,'#FFFFFF','#1A1CA1',n,'12px Arial',n,'none',0,n,4,1);
var s0=awmCreateMenu(0,0,0,0,1,0,1,0,0,30,30,0,1,1,0,n,"",n,1,1,0,1,n,n,100);
var s1=it.addSubmenu(0,0,-20,2,3,0,1,5,4,n,"",n,1,8,1,0,n,n,100);
$get_cats=mysql_query("select sql_cache distinct annonce_type_bien from annonces order by annonce_type_bien");
while ($cat=mysql_fetch_array($get_cats)) {
      echo "it=s1.addItem(6,7,7,\"&nbsp;&nbsp;".$catnom."s&nbsp;&nbsp;\",n,n,\"\",\"\",n,n,n,\"../en/search.php?cat=".$cat['annonce_type_bien']."\",n);\n";

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I go to the home page. Click Apartments tab, let the page load. No javascript warnings or errors (using IE 6). I'm using my office computer though, and apparently didn't have flash installed, so it did make me install that for your '/flash/ocean.swf' file.
It is working for me as well.

You might want to try my service at http://JSBugHunter.Com for detecting this type of Javascript Errors. It might assist you in pinpointing what clients get the error and maybe even tell you where exactly does the error happen.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dniryAuthor Commented:
Hmmm, weird... I am using IE6 as well (build 6.0.2900.2180.xpsp_sp2_gdr.050301-1519) on XP Pro SP2. I tested as well from a Win2K Advanced Server box with IE6 (build 6.0.2800.1106) and am getting it as well (exact JS warning is "Object Expected", line 398). Reload the page, warning is gone.

Works fine on Firefox though.

I'll wait a few more days to see if someone else can help me find the solution. If not, I'll give the points to SnowFlake for providing the link to this very useful JSBugHunter service which I've added to my bookmarks :-)

Many thanks to both of you anyway for taking the time to look at this.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.