Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Javascripts not compatible with IE
Old 05-26-2009, 03:10 PM Javascripts not compatible with IE
wildbackpacker's Avatar
Extreme Talker

Posts: 162
Name: Colton
Location: Utah, USA
Trades: 0
I'm redesigning a high school's website, and I've been testing the site in FireFox. Well now I know to test it in IE also. On the departments page, I have the individual department navigation on the right using an ajax script that loads an external page into a div on the departments page.


Code:
/* Ultimater's edited version of:
   http://jibbering.com/2002/4/httprequest.html
   to serve IE7 with XMLHttpRequest instead of ActiveX */

var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
     try {
          xmlhttp = new XMLHttpRequest();
     } catch (e) {
          xmlhttp=false;
     }
}

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
if (!xmlhttp){
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
}
@end @*/

if (!xmlhttp && window.createRequest) {
    try {
        xmlhttp = window.createRequest();
    } catch (e) {
        xmlhttp=false;
    }
}

/* Ultimater's edited version of:
   http://javascript.internet.com/ajax/ajax-navigation.html */

var please_wait = " ";

function open_url(url, targetId) {
  if(!xmlhttp)return false;
    var e=document.getElementById(targetId);if(!e)return false;
    if(please_wait)e.innerHTML = please_wait;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() { response(url, e); }
    try{
      xmlhttp.send(null);
    }catch(l){
    while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
    e.appendChild(document.createTextNode("request failed"));
  }
}

function response(url, e) {
  if(xmlhttp.readyState != 4)return;
    var tmp= (xmlhttp.status == 200 || xmlhttp.status == 0) ? xmlhttp.responseText : "Ooops!! A broken link! Please contact the webmaster of this website ASAP and give him the following error code: " + xmlhttp.status+" "+xmlhttp.statusText;
    var d=document.createElement("div");
    d.innerHTML=tmp;
    setTimeout(function(){
      while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
      e.appendChild(d);
    },10)
}
Code:
<a href="javascript:void(0)" onclick="open_url('departments/admin.html','contentarea');">Administration</a>
Each department page also includes a list of teachers that the user can click on.

Code:
<script language="JavaScript1.2">
var qt = new Array(5);

qt[1]="<img src=departments/staff/haslam.jpg class=contentPhotoright height=105 width=80 /><br><br><br><br><br><h3>Mr. Haslam</h3><a href=mailto:jdhaslam@graniteschoolsorg>jdhaslam@graniteschools.org</a><br><br>Mr. Haslam received his Bachelor of Science Degree in Education at Southern Utah State College. ...... 2003.";

qt[2]="<img src=departments/staff/haslam.jpg class=contentPhotoright height=105 width=80 /><br><br><br><br><br><h3>Mr. Horton</h3><a href=mailto:rshorton@graniteschoolsorg>rshorton@graniteschools.org</a><br><br>Mr. Haslam received his Bachelor of Science Degree in Education at Southern Utah State College. ...... Taylorsville in 2003.";

qt[3]="<img src=departments/staff/crawford.jpg class=contentPhotoright height=105 width=80 /><br><br><br><br><br><h3>Mr. Crawford</h3><a href=mailto:jdhaslam@graniteschoolsorg>jdhaslam@graniteschools.org</a><br><br>Mr. Haslam received his Bachelor of Science Degree in Education at Southern Utah State College. ..... 2003.";   

qt[4]=""It is only as we develope others that we permanently succeed." Harvey Firestone";  

qt[5]=" "; 
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1;
var ns4=document.layers;
var ns6=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1;
function dq(content){
  content=qt[content];
  if(ie4){showContentObj=document.all.div_id;}
  if(ns6){showContentObj=document.getElementById("content");}
  if(ie4||ns6){
    if(showContentObj.innerHTML!=content){showContentObj.innerHTML=content;}
    else{showContentObj.innerHTML="";}
  }
  if(ns4){document.ns_div.document.write(content); document.ns_div.document.close();}
}
</script>
Code:
<a href="javascript:void(0)" onclick="dq('1')">Mr. Haslam</a>
These scripts work just how I want them to in Mozilla Firefox 3, but they don't work correctly or not at all in IE6. Is there any way I can modify these scripts to be compatible with IE? I'm a beginner and I'm behind on my deadline, so I would be so appreciative of anyone who could solve this problem for me. Thanks!
__________________
Colton
Wild Backpacker

Please login or register to view this content. Registration is FREE
wildbackpacker is offline
Reply With Quote
View Public Profile Visit wildbackpacker's homepage!
 
 
Register now for full access!
Old 05-26-2009, 04:16 PM Re: Javascripts not compatible with IE
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Sorry, I tried, but js debugging in IE is the worst thing that I ever had to do, and it's stil the same.
The microsoft script debugger gives me an error on a <div> tag (that thing is completly lost) and I never have found anything even as close as 10% of firebug for IE.

But my guess is that the problem lies into open_url().
You have a lot of global variables being used in there, and the problem is certainly that the scope in IE is different than the other.
Try to add a bunch of echo() to see if it's in that function that the problem is located, and make your way up to the point where the script fail.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 05-27-2009, 01:51 AM Re: Javascripts not compatible with IE
wildbackpacker's Avatar
Extreme Talker

Posts: 162
Name: Colton
Location: Utah, USA
Trades: 0
Okay I'll give that I try. Thanks.
__________________
Colton
Wild Backpacker

Please login or register to view this content. Registration is FREE
wildbackpacker is offline
Reply With Quote
View Public Profile Visit wildbackpacker's homepage!
 
Old 05-28-2009, 08:40 AM Re: Javascripts not compatible with IE
Average Talker

Posts: 15
Trades: 0
i am trying out on my own and will inform you as soon as i get any positive output from it.
__________________

Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE
(web hosting at 50% off),
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
( free ads posting)
bholu is offline
Reply With Quote
View Public Profile
 
Old 05-28-2009, 11:19 AM Re: Javascripts not compatible with IE
wildbackpacker's Avatar
Extreme Talker

Posts: 162
Name: Colton
Location: Utah, USA
Trades: 0
Okay thank you so much bholu! If you find a solution, I will be eternally grateful.
__________________
Colton
Wild Backpacker

Please login or register to view this content. Registration is FREE
wildbackpacker is offline
Reply With Quote
View Public Profile Visit wildbackpacker's homepage!
 
Reply     « Reply to Javascripts not compatible with IE
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32956 seconds with 12 queries