ChaosKnight Posted January 11, 2009 Share Posted January 11, 2009 Hey guys, I posted on the PHP forum because I originally thought my error had to do with PHP or MySQL but know I found out it's a Javascript runtime error which only occurs in IE... The link to the site is: http://www.hotels-tours-safaris.com/new_site/index.php I have 3 external js files uploaded there: s_loader.js -- Throws out a 'document' is undefined error /s_arrays.js --Throws out an Object unexpected error s_script_dom.js --Throws out 's_Es' is undefined On the PHP forum they said the biggest one of the 3 errors is the 'document' is undefined one... IE says the error is located on Line 8 Char 1, the first thing on line 8 is the following: s_x=document; What can the cause possibly be? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/140394-javascript-runtime-errors-in-ie/ Share on other sites More sharing options...
corbin Posted January 11, 2009 Share Posted January 11, 2009 Document might not be loaded yet at that point. If that is the case, you will have to move the <script> tag into the body, or you could use an onload thing to set it in a function. Quote Link to comment https://forums.phpfreaks.com/topic/140394-javascript-runtime-errors-in-ie/#findComment-734741 Share on other sites More sharing options...
ChaosKnight Posted January 11, 2009 Author Share Posted January 11, 2009 The s_loader file already get's called in the body Here's s_loader's code: s_The_Arrays_Source='s_arrays.js';// the source of the menu definitions s_Script_DOM_Source='s_script_dom.js';// the source of your script s_Script_NS4_Source='s_script_ns4.js'; s_Script_OLD_Source='s_script_old.js'; s_Any_Add_On_Source='';// if you need any add-on // === s_x=document;s_ua=navigator.userAgent.toLowerCase();s_dl=s_x.getElementById?1:0;s_iE=s_x.all&&!window.innerWidth&&s_ua.indexOf("msie")!=-1?1:0;s_oP=s_ua.indexOf("opera")!=-1&&s_x.clear?1:0;s_oP7=s_oP&&s_x.appendChild?1:0;s_oP7m=s_oP&&!s_oP7?1:0;s_nS=s_dl&&!s_x.all&&s_ua.indexOf("opera")==-1?1:0;s_nS4=s_x.layers?1:0;s_kNv=s_ua.indexOf("konqueror")!=-1?parseFloat(s_ua.substring(s_ua.indexOf("konqueror/")+10)):0;s_kN=s_kNv>=2.2?1:0;s_kN3p=s_kNv>=3?1:0;s_kN31p=s_kNv>=3.1?1:0;s_kN32p=s_kNv>=3.2?1:0;s_mC=s_ua.indexOf("mac")!=-1?1:0;s_sF=s_mC&&s_ua.indexOf("safari")!=-1?1:0;s_eS=s_ua.indexOf("escape")!=-1?1:0;s_iE5M=s_mC&&s_iE&&s_dl&&!s_eS?1:0;s_iE4=!s_mC&&s_iE&&!s_dl?1:0;s_ct=0;var s_ML,s_AL;s_=[""];s_a="undefined";s_1=[];s_2=[];function s_add(a,b){s_ct++;s_[s_ct]=[];s_[s_ct][0]={IEF:a.S[17],B:a.S[3],BC:a.S[0],BCNS4:a.S[1],BW:a.S[2],PD:a.S[4],SC:a.S[27],SCT:a.S[28],SCB:a.S[29],SCW:a.S[30],SCH:a.S[31]};for(var k in a)s_[s_ct][0][k]=a[k];for(var i=0;i<b.length;i++){if(s_autoSELECTED){if(b.Show&&b.Show!=""){if(typeof s_1[b.Show]==s_a)s_1[b.Show]=[];s_1[b.Show][s_1[b.Show].length]=[s_ct,i+1]}var u,h,t;h=location.href;u=b.U;t=h.substring(h.length-u.length);if(t==u&&u!=""){s_2[s_2.length]=a.N;b.SELECTED=false;if(!s_autoSELECTEDItemsClickable)b.U=""}}s_[s_ct][i+1]={BgColor:b.SELECTED?a.S[24]:a.S[5],OverBgColor:a.S[6],FontColor:b.SELECTED?a.S[25]:a.S[7],OverFontColor:a.S[8],FontFamily:a.S[9],FontSize:a.S[10],FontSizeNS4:a.S[11],FontWeight:a.S[12],TextAlign:a.S[13],Padding:a.S[14],SeparatorSize:a.S[15],SeparatorColor:a.S[16],UseSubImg:a.S[18],SubImgSrc:b.SELECTED?a.S[26]:a.S[19],OverSubImgSrc:a.S[20],SubImgWidth:a.S[21],SubImgHeight:a.S[22],SubImgTop:a.S[23],Target:s_target,Class:b.SELECTED?a.S[34]:a.S[32],OverClass:b.SELECTED?a.S[34]:a.S[33],BorderColor:b.SELECTED?a.S[38]:a.S[36],OverBorderColor:a.S[37],BorderWidth:a.S[35]?a.S[35]:0,SeparatorSpacing:a.S[39]?a.S[39]:0,SeparatorBgImage:a.S[40]};for(var j in b)s_[s_ct][i+1][j]=b[j];if(b.BgImage){s_[s_ct][i+1].FS=new Image;s_[s_ct][i+1].FS.src=b.BgImage}if(b.OnBgImage){s_[s_ct][i+1].NS=new Image;s_[s_ct][i+1].NS.src=b.OnBgImage}if(b.Image){s_[s_ct][i+1].Fs=new Image;s_[s_ct][i+1].Fs.src=b.Image[0]}if(b.OnImage){s_[s_ct][i+1].Ns=new Image;s_[s_ct][i+1].Ns.src=b.OnImage}}};s_tm1="<script language=JavaScript1.2 src='"+s_The_Arrays_Source+"' type=text/javascript></script>";s_tm2="<script language=JavaScript1.2 src='"+(s_nS4?s_Script_NS4_Source:s_iE&&!s_dl||s_kN&&!s_kN3p||s_oP7m?s_Script_OLD_Source:s_Script_DOM_Source)+"' type=text/javascript></script>";s_tm3=s_Any_Add_On_Source!=""?"<script language=JavaScript1.2 src='"+s_Any_Add_On_Source+"' type=text/javascript></script>":"";if(s_iE||s_nS4||s_nS||s_oP){s_x.write(s_tm1);s_x.write(s_tm2);if(s_tm3!="")s_x.write(s_tm3)}if(s_kN)s_x.write(s_tm1+s_tm2+s_tm3); (Please excuse me for my code not being in a code box, but it didn't display all the lines) As you can see I call the rest through the s_loader seeing that it's s_loader's function... s_loader calls the different scripts depending on the browser... If you think this is unnecessary please advise, or if there is an easier way to get through this mess with some easier code please advise me ASAP... Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/140394-javascript-runtime-errors-in-ie/#findComment-734752 Share on other sites More sharing options...
ChaosKnight Posted January 11, 2009 Author Share Posted January 11, 2009 Do you think the file s_script_dom throws out the error s_eS undefined seeing that I didn't make it global by using var? And In the code above I used eval, is there another way I could use seeing that I want to disable eval in PHP Quote Link to comment https://forums.phpfreaks.com/topic/140394-javascript-runtime-errors-in-ie/#findComment-734763 Share on other sites More sharing options...
corbin Posted January 11, 2009 Share Posted January 11, 2009 Hrmmm, in Firefox with Firebug, I don't get any of the errors you mentioned, oddly enough. lol. Are you using IE? I never trust IE's JS debugging. It's horrible. The errors I get in firebug: missing ) after argument list MM_preloadImages('images/web_04_ro.jpg',...tal_ro.gif','images/maps_ro.gif','images http://www.hotels-tours-safaris.com/new_site/index.php Line 1 invalid label http://www.hotels-tours-safaris.com/new_site/s_arrays.js (line 95) [break on this error] nS4?document.layers["s_m"+s_P]:s_getO...nload:function(){};window.onload:functio s_rightToLeft is not defined http://www.hotels-tours-safaris.com/new_site/s_script_dom.js Line 1 if(s_eS)event=null;s_tmp="";s_T=s_ST=s_h...s_ld()",50)};for(s_j=1;s_j<=s_ct;s_j++){ Quote Link to comment https://forums.phpfreaks.com/topic/140394-javascript-runtime-errors-in-ie/#findComment-734902 Share on other sites More sharing options...
ChaosKnight Posted January 12, 2009 Author Share Posted January 12, 2009 That makes it a lot more clearer thanks! But as you can see below, there is a ) after the MM_preloadImages argument... <body onload="MM_preloadImages('images/web_04_ro.jpg','images/web_05_ro.jpg','images/web_06_ro.jpg','images/web_07_ro.jpg','images/home_ro.gif','images/countries.gif','images/countries_ro.gif,'images/about_ro.gif','images/car_rental_ro.gif','images/maps_ro.gif','images/bookings_ro.gif','images/contact_ro.gif','subnav/southafrica','subnav/southafrica_ro','subnav/kenya','subnav/kenya_ro','subnav/botswana','subnav/botswana_ro' )" > Why do you think that'll make Firebug see a problem? But it shouldn't be too much of a problem... The 2 other error's makes me a bit confused... How will a be able to fix them? Sorry, I'm still a newbie with JavaScript... But that'll change shortly!! Quote Link to comment https://forums.phpfreaks.com/topic/140394-javascript-runtime-errors-in-ie/#findComment-735165 Share on other sites More sharing options...
ChaosKnight Posted January 13, 2009 Author Share Posted January 13, 2009 Does anybody know what book I can get that includes the basics, the anvanced stuff and some things about ajax? Does it include browser difference stuff? I learned noyhing from JavaScript for dummies, but I want to fix that with another book that also handles really anvanced things like handling the browser etc... I heard good remarks about JavaScript Bible 6, would you also recommend it? Quote Link to comment https://forums.phpfreaks.com/topic/140394-javascript-runtime-errors-in-ie/#findComment-736036 Share on other sites More sharing options...
ChaosKnight Posted January 31, 2009 Author Share Posted January 31, 2009 Could anyone have figured out my problem yet? I don't want to make the same mistake again, please assist... Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/140394-javascript-runtime-errors-in-ie/#findComment-751427 Share on other sites More sharing options...
KevinM1 Posted January 31, 2009 Share Posted January 31, 2009 Does anybody know what book I can get that includes the basics, the anvanced stuff and some things about ajax? Does it include browser difference stuff? I learned noyhing from JavaScript for dummies, but I want to fix that with another book that also handles really anvanced things like handling the browser etc... I heard good remarks about JavaScript Bible 6, would you also recommend it? I haven't read JavaScript Bible at all. If it's like the other Bible books I do have (Ubuntu, and Ajax), it may be a bit hit or miss. I learned JavaScript through two books: JavaScript & DHTML Cookbook by Danny Goodman. It's a decent primer for beginners, and how to start thinking in JavaScript. Pro JavaScript Techniques by John Resig. I love this book. I consider it to be the best book on JavaScript available. Regarding browser differences, a good rule of thumb is to ignore older browsers (IE 5 and whatnot). Instead, code for what Yahoo terms as 'A-grade' and the equivalent 'X-grade' browsers, such as FireFox 3 for Linux or Google Chrome (http://developer.yahoo.com/yui/articles/gbs/index.html). These are all considered to be modern browsers, and are what you should focus on when coding. There are still differences between even the modern browsers, but in my experience the kinks really only show themselves during testing. I haven't yet found a centralized place describing all the 'gotchas' that can show up when developing for modern browsers. Just be sure to test your code on different browsers, with IE and FireFox being the two key browsers. And burn your 'For Dummies' book. Those books all tend to suck. Not worth the paper they're printed on, IMO. Quote Link to comment https://forums.phpfreaks.com/topic/140394-javascript-runtime-errors-in-ie/#findComment-751529 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.