Connecting Tech Pros Worldwide Forums | Help | Site Map

null or not an object error in IE works perfectly in Firefox

Newbie
 
Join Date: May 2007
Posts: 3
#1: May 18 '07
Expand|Select|Wrap|Line Numbers
  1. // JavaScript Document
  2. var easy = "046280000500600740200000000005032070021000480030170500000000005094001007000096830";
  3. var easySplit = easy.split('');
  4. var eAns = "946287351583619742217543698865432179721965483439178526678324915394851267152796834";
  5. var eAnspl = eAns.split('');
  6. var medium = "000800017430000000002000900200008000097603480000700005006000100000000048580001000";
  7. var medSplit = medium.split('');
  8. var medAns = '659824317431597826872136954265948731197653482348712695926485173713269548584371269';
  9. var mAnspl = medAns.split('');
  10. var hard = "900001050765000000100300008000006040000218000090400000600004002000000837030100005";
  11. var hardSplit = hard.split('');
  12. var hardAns = '983721654765849321124365798817956243346218579592473186678534912451692837239187465';
  13. var hAnspl = hardAns.split('');
  14.  
  15. var sudokuTable = {
  16.  
  17.     nonjsTable:function()
  18.     {
  19.         document.forms['sudo'].reset();
  20.         var table = document.getElementById('sudoForm');
  21.         var inp = table.getElementsByTagName('input');
  22.         for(var i=0; i<81; i++){
  23.  
  24.             inp[i].setAttribute('id', (i+1));
  25.             inp[i].setAttribute('readonly', 'true');
  26.             inp[i].setAttribute('onchange', 'levels.change(this.id)');
  27.         }
  28.     }
  29.  
  30. }
  31.  
  32.  
  33. // deals with function to load numbers for each level
  34.  
  35. var levels = {
  36.         eCheck : easy.split(''),
  37.         mCheck : medium.split(''),
  38.         hCheck : hard.split(''),
  39.         box : null,
  40.         current : null,
  41.         lev : null,
  42.         levnans : null,
  43.         //cell : document.getElementById('sudoForm'),
  44.  
  45.     cLevels:function(levSplit, answer)
  46.     {
  47.         levels.levans = answer;
  48.         levels.lev = levSplit;
  49.         levels.eCheck = easy.split('');
  50.         document.forms['sudo'].reset();
  51.  
  52.         for(var i=0; i<81; i++)
  53.         {
  54.             if(levSplit[i]==0)
  55.             {
  56.                 document.forms['sudo'].elements[i].setAttribute('value', '');
  57.                 document.forms['sudo'].elements[i].removeAttribute('readonly');
  58.             }
  59.             else
  60.             {
  61.                 document.forms['sudo'].elements[i].setAttribute('value', levSplit[i]); 
  62.                 document.forms['sudo'].elements[i].setAttribute('readonly', 'true' );
  63.             }
  64.  
  65.         }
  66.  
  67.     },
  68.  
  69.     change:function(d)
  70.     {
  71.         levels.box = document.getElementById(d);
  72.         levels.current = levels.levans[d-1];
  73.         if(levels.box.value==0)
  74.         {
  75.             levels.box.value = '';
  76.         }
  77.     },
  78.  
  79.     check:function()
  80.     {
  81.         if(levels.box.value==levels.current)
  82.         {
  83.             alert('The value is correct');
  84.         }
  85.         else
  86.         {
  87.             alert('incorrect value..please try again');
  88.         }
  89.     }
  90.  
  91.  
  92.  
  93. }
I would say i am a novice at javascript and i had this project to do for university for a sudoku game. The code works fine in firefox but tells me that levels.box is null or not an object for some reason. It would be great if someone could help me out as i am not sure why IE does this. Thanks in advance for your help.

Moj

Newbie
 
Join Date: May 2007
Posts: 3
#2: May 19 '07

re: null or not an object error in IE works perfectly in Firefox


found a solution. basically Internet Explorer is crappy and doesnt like the setAttribute property so had to change the onchange handler by directly changing the attrbute for the object like so.
object.onchange = function() {}

Incase anyone has a problem like this i hope the solution helps

Moj
Newbie
 
Join Date: Jun 2007
Posts: 1
#3: Jun 22 '07

re: null or not an object error in IE works perfectly in Firefox


Hi,

Would you be able to paste in your new code. I'm having the exact same problem, I just don't know how to apply what you wrote: object.onchange=function(){}.

Thanks
grim



Quote:

Originally Posted by modeep

found a solution. basically Internet Explorer is crappy and doesnt like the setAttribute property so had to change the onchange handler by directly changing the attrbute for the object like so.
object.onchange = function() {}

Incase anyone has a problem like this i hope the solution helps

Moj

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Jun 23 '07

re: null or not an object error in IE works perfectly in Firefox


Quote:

Originally Posted by grimlockhale

Hi,

Would you be able to paste in your new code. I'm having the exact same problem, I just don't know how to apply what you wrote: object.onchange=function(){}.

Thanks
grim

Welcome to TSDN!

I am assuming he meant line 26 which would be changed to:
Expand|Select|Wrap|Line Numbers
  1. inp[i].onchange = function() {...
If you can't solve it post your code (using code tags please).
Newbie
 
Join Date: Dec 2007
Posts: 6
#5: Dec 30 '07

re: null or not an object error in IE works perfectly in Firefox


I'm working on a piece of code... I can't get it work with IE, but in FF all is fine...
I think the problem is what you're talking about here, but I can't understand what to do with my code...
Here it is:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Google Maps Mod
  3. // by
  4. // TLM --- Taken Over By brianjw <brianjw@verizon.net>
  5.  
  6. // We calling this directly, if so, your evil...
  7. if (!defined('SMF'))
  8.     die('Hacking attempt...');
  9.  
  10. function Map() {
  11.     global $db_prefix, $context;
  12.  
  13.     // Are we allowed to view the map? Keep in mind here we should be a guest unless user is in IE!
  14.     isAllowedTo('googleMap_view');
  15.  
  16.  
  17.     //Lets try this to make it work on first click...
  18.     //loadUserSettings();
  19.     writeLog();
  20.  
  21.     //Map using the internal XML File? Or the JS file?
  22.     if (isset($_GET['sa']) && $_GET['sa'] == '.xml')
  23.         return MapsXML();
  24.        if (isset($_GET['sa']) && $_GET['sa'] == '.js')
  25.         return MapsJS();
  26.  
  27.     // Get the template ready.... not really much else to do.
  28.     //loadLanguage('MemberMap');
  29.     loadTemplate('GoogleMap');
  30.     $context['sub_template'] = 'map';
  31.     $context['page_title'] = "Mappa Utenti";
  32. }
  33.  
  34. function MapsJS() {
  35.     global $db_prefix, $context, $scripturl, $txt, $modSettings, $user_info;
  36.  
  37.     // Lets dump everything in the buffer and start clean and new and fresh
  38.     ob_end_clean();
  39.     if (!empty($modSettings['enableCompressedOutput']))
  40.         @ob_start('ob_gzhandler');
  41.     else
  42.         ob_start();
  43.  
  44. echo '
  45.     // arrays to hold copies of the markers and html used by the sidebar
  46.     // because the function closure trick doesnt work there
  47.     var gmarkers = [];
  48.     var htmls = [];
  49.  
  50.     // This function picks up the click and opens the corresponding info window
  51.     function myclick(i) {
  52.       gmarkers[i].openInfoWindowHtml(htmls[i]);
  53.     }
  54.  
  55. function MakeMap() {
  56.     // Globals.
  57.     //Icon(s), and if gender is enabled, php will allow those to be defined.
  58.     var icon = new GIcon();
  59.     icon.image = "http://labs.google.com/ridefinder/images/mm_20_green.png";
  60.     icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
  61.     icon.iconSize = new GSize(12, 20);
  62.     icon.shadowSize = new GSize(22, 20);
  63.     icon.iconAnchor = new GPoint(6, 20);
  64.     icon.infoWindowAnchor = new GPoint(5, 1);
  65.     // For that lovly clustering thing!
  66.     var clusterIcon = new GIcon();
  67.     clusterIcon.image = "http://labs.google.com/ridefinder/images/mm_20_purple.png";
  68.     clusterIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
  69.     clusterIcon.iconSize = new GSize(12, 20);
  70.     clusterIcon.shadowSize = new GSize(22, 20);
  71.     clusterIcon.iconAnchor = new GPoint(6, 20);
  72.     clusterIcon.infoWindowAnchor = new GPoint(5, 1);';
  73. if ($modSettings['googleMapsPinGender'])
  74. echo '
  75.     var iconm = new GIcon();
  76.     iconm.image = "http://labs.google.com/ridefinder/images/mm_20_blue.png";
  77.     iconm.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
  78.     iconm.iconSize = new GSize(12, 20);
  79.     iconm.shadowSize = new GSize(22, 20);
  80.     iconm.iconAnchor = new GPoint(6, 20);
  81.     iconm.infoWindowAnchor = new GPoint(5, 1);
  82.     var iconf = new GIcon();
  83.     iconf.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
  84.     iconf.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
  85.     iconf.iconSize = new GSize(12, 20);
  86.     iconf.shadowSize = new GSize(22, 20);
  87.     iconf.iconAnchor = new GPoint(6, 20);
  88.     iconf.infoWindowAnchor = new GPoint(5, 1);';
  89.  
  90. echo '
  91.     if (GBrowserIsCompatible()) {
  92.         // this variable will collect the html which will eventually be placed in the sidebar
  93.         var sidebar_html = "";
  94.  
  95.         var i = 0;
  96.  
  97.         // A function to create the marker and set up the event window
  98.         function createMarker(point, icon, name, html) {
  99.             var marker = new GMarker(point, icon);
  100.             GEvent.addListener(marker, "click", function() {
  101.             map.getCenter(point);
  102.             marker.openInfoWindowHtml(html);
  103.             });
  104.             // save the info we need to use later for the sidebar
  105.             gmarkers[i] = marker;
  106.             htmls[i] = html;
  107.             // add a line to the sidebar html';
  108. if ($modSettings['googleSidebar'] == 1)
  109. echo '
  110.             sidebar_html += \'<a href="javascript:myclick(\' + i + \')">\' + name + \'</a><br /> \';';
  111. if ($modSettings['googleSidebar'] == 2)
  112. echo '
  113.             sidebar_html += \'<a href="javascript:myclick(\' + i + \')">\' + name + \'</a>, \';';
  114. echo '
  115.             //Now that we cached it lets return the marker....
  116.             i++;
  117.             return marker;
  118.         }
  119.  
  120.         // create the map
  121.         var map = new GMap2(document.getElementById("map"));
  122.         map.addControl(new GLargeMapControl());
  123.         map.addControl(new GMapTypeControl());
  124.         // Sets the map type based on admin prefrence API 1 !!!
  125.         //map.setMapType(' . $modSettings['googleMapsType'] . ');
  126.         //Kartenübersicht
  127.           map.addControl(new GOverviewMapControl(new GSize(100,75)));
  128.         // Lets load up the default long/lat/zoom for the map for those that like wine.
  129.         map.setCenter(new GLatLng(' . $modSettings['googleMapsDefaultLat'] . ', ' . $modSettings['googleMapsDefaultLong'] . '), ' . $modSettings['googleMapsDefaultZoom'] . ',' . $modSettings['googleMapsType'] . ');
  130.  
  131.         // This is so we can try to cluster some of those pins together so the map does not get over loaded?
  132.         var clusterer = new Clusterer( map );
  133.         clusterer.icon = clusterIcon;
  134.         clusterer.minMarkersPerClusterer = ' . $modSettings['googleMapsMinMarkerCluster'] . ';
  135.         clusterer.maxVisibleMarkers = ' . $modSettings['googleMapsMaxVisMarker'] . ';
  136.         clusterer.GridSize = ' . $modSettings['googleMapsMaxNumClusters'] . ';
  137.         clusterer.MaxLinesPerInfoBox = ' . $modSettings['googleMapsMaxLinesCluster'] . ';
  138.  
  139.         // Read the data
  140.         var request = GXmlHttp.create();
  141.         request.open("GET", "'. $scripturl . '?action=googlemap;sa=.xml", true);
  142.  
  143.         request.onreadystatechange = function() {
  144.             if (request.readyState == 4) {
  145.                 var xmlDoc = request.responseXML;
  146.                 // obtain the array of markers and loop through it
  147.                 var markers = xmlDoc.documentElement.getElementsByTagName("marker");
  148.  
  149.                 for (var i = 0; i < markers.length; i++) {
  150.                     // obtain the attribues of each marker
  151.                     var lat = parseFloat(markers[i].getAttribute("lat"));
  152.                     var lng = parseFloat(markers[i].getAttribute("lng"));
  153.                     var point = new GLatLng(lat,lng);
  154.                     var html = markers[i].getAttribute("html");
  155.                     var label = markers[i].getAttribute("label");
  156.                     // create the marker';
  157. if ($modSettings['googleMapsPinGender'])
  158. echo '
  159.                         if (parseFloat(markers[i].getAttribute("gender")) == 0)
  160.                             var marker = createMarker(point, icon, label, html);
  161.                         if (parseFloat(markers[i].getAttribute("gender")) == 1)
  162.                             var marker = createMarker(point, iconm, label, html);
  163.                         if (parseFloat(markers[i].getAttribute("gender")) == 2)
  164.                             var marker = createMarker(point, iconf, label, html);';
  165. else
  166. echo '
  167.                         var marker = createMarker(point, icon, label, html);';
  168. if ($modSettings['googleMapsEnableClusterer'])
  169.     echo '
  170.                     clusterer.AddMarker(marker, label);';
  171. else
  172.     echo '
  173.                     map.addOverlay(marker);';
  174. echo '
  175.                 }
  176.             // put the assembled sidebar_html contents into the sidebar div
  177.             document.getElementById("sidebar").innerHTML = sidebar_html;
  178.             }
  179.         }
  180.         request.send(null);
  181.     } else {
  182.       alert("Sorry, the Google Maps API is not compatible with this browser");
  183.     }
  184. }
  185.     setTimeout(\'MakeMap()\', 500);
  186. ';
  187.       obExit(false);
  188. }
Can you help me, please?
Bye,
PS
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#6: Dec 30 '07

re: null or not an object error in IE works perfectly in Firefox


A bug in the code tag software means that the code will have to be split up across multiple posts. Here's the second part:
Expand|Select|Wrap|Line Numbers
  1. function MapsXML() {
  2.     global $db_prefix, $context, $scripturl, $txt, $modSettings, $user_info, $themeUser, $memberContext;
  3.  
  4.     // Lets dump everything in the buffer and start clean and new and fresh
  5.     ob_end_clean();
  6.     if (!empty($modSettings['enableCompressedOutput']))
  7.         @ob_start('ob_gzhandler');
  8.     else
  9.         ob_start();
  10.  
  11.     // XML Header
  12.     //header("Content-Type: plain/text; charset=UTF-8");
  13.     header("Content-Type: application/xml; charset=UTF-8");
  14.  
  15.     // Lets find number of members that set there map
  16.     $request = db_query("
  17.     SELECT COUNT(*) as TOTALFOUND
  18.     FROM {$db_prefix}members
  19.     WHERE latitude IS NOT NULL AND longitude IS NOT NULL
  20.     ", __FILE__, __LINE__);
  21.  
  22.     // Pull the answer and store it...
  23.     $totalSet = mysql_fetch_row($request);
  24.  
  25.     // If the total people set there lat/long is greater than googleMapsPinNumber,
  26.     // We check for if we have any bounds that got passed from the JS,
  27.     // If no bounds we just pick the number of googleMapsPinNumber to show...
  28.     // If we are under the max allowed, just show them all!
  29.     if ($totalSet[0] >= $modSettings['googleMapsPinNumber']) {
  30.         // Lets set this to nothing, just to be safe if we dont have variables...
  31.         $sql_addon = "";
  32.  
  33.         // Check to see if we have any ranges before we add to the SQL statment...
  34.         // This could stand to have a bit better security on it but its gonna be let by the side for now
  35.         if ((isset($_GET['minX'])) && (isset($_GET['maxX'])) && (isset($_GET['minY'])) && (isset($_GET['maxY']))) {
  36.             $sql_addon = " AND latitude > " . $_GET['minX'] . "
  37.             AND latitude < " . $_GET['maxX'] . "
  38.             AND longitude > " . $_GET['minY'] . "
  39.             AND longitude < " . $_GET['maxY'];
  40.         }
  41.  
  42.         // Lets just make this simple for the query...
  43.         $maxPins = $modSettings['googleMapsPinNumber'];
  44.  
  45.         // Load the data up at random to the ping count!
  46.         $query = "SELECT *
  47.         FROM {$db_prefix}members
  48.         WHERE latitude IS NOT NULL AND longitude IS NOT NULL
  49.         $sql_addon
  50.         ORDER BY RAND()
  51.         LIMIT 0, $maxPins";
  52.     } else {
  53.         // Looks like we passed under the max, Load everyone...
  54.         $query = "SELECT *
  55.         FROM {$db_prefix}members
  56.         WHERE latitude IS NOT NULL AND longitude IS NOT NULL
  57.         ORDER BY `realName` ASC ";
  58.     }
  59.  
  60.     $request = db_query($query, __FILE__, __LINE__);
  61.  
  62.     //Ok this is block of code takes care of the entire load all member data into $themeUser/$memberContext on per # basis
  63.     $temp = array();
  64.     while ($row = mysql_fetch_array($request, MYSQL_ASSOC))
  65.         $temp[] = $row['ID_MEMBER'];
  66.     loadMemberData($temp);
  67.     foreach ($temp as $v)
  68.         loadMemberContext($v);
  69.  
  70.     // Seeing how SMF 1.0 uses $themeUser and SMF 1.1 uses $memberContext, lets just make our own now?
  71.     if (isset($memberContext))
  72.         $data = $memberContext;
  73.     elseif (isset($themeUser))
  74.         $data = $themeUser;
  75.  
  76.     // Lets accualy start making XML Mr. PHP
  77.     echo '<?xml version="1.0" encoding="UTF-8"?>
  78.     <markers>';
  79.  
  80.     if (isset($data)) {
  81.     // Assuming we have data to work with...
  82.         foreach ($data as $marker) {
  83.                 $datablurb = '
  84.                 <table class="googleMaps" border="0">
  85.                     <tr>
  86.                         <td style="white-space: nowrap;" align="left"><a href="' . $marker['online']['href'] . '"><img src="' . $marker['online']['image_href'] . '" alt="' . $marker['online']['text'] .'" class="avatar" border="0" /></a> <a href="' . $marker['href'] .'">' . $marker['name'] . '</a></td>
  87.                         <td rowspan="3">' . $marker['avatar']['image'] . '</td>
  88.                     </tr><tr>
  89.                         <td style="white-space: nowrap;"><font color="#000000">' . $marker['title'] . '</font></td>
  90.                        </tr><tr>
  91.                         <td style="white-space: nowrap;" align="center">
  92.                             ' . $marker['icq']['link'] . '
  93.                             ' . $marker['aim']['link'] . '
  94.                             ' . $marker['yim']['link'] . '
  95.                             ' . $marker['msn']['link'] . '
  96.                         </td>
  97.                     </tr><tr>
  98.                         <td style="white-space: nowrap;" colspan="2" align="left">';
  99.                 if (($marker['website']['url'] != '') && ($marker['website']['title'] != ''))
  100.                      $datablurb = $datablurb . '<a href="' . $marker['website']['url'] . '">' . $marker['website']['title'] . '</a>';
  101.                 $datablurb = $datablurb . '</td>
  102.                     </tr><tr>
  103.                         <td style="white-space: nowrap;" colspan="2" align="left"><font color="#000000">' . $marker['blurb'] . '</font></td>
  104.                     </tr>
  105.                 </table>';
  106.  
  107.                 // This is to help against those funky chars... and protect against those " errors in XML!
  108.                 $datablurb = htmlspecialchars($datablurb);
  109.  
  110.                 // Lets bring it all together...
  111.                 $markers = '<marker lat="' . $marker['googleMap']['latitude'] . '" lng="' . $marker['googleMap']['longitude'] . '" ';
  112.  
  113.                 if ($marker['gender']['name'] == $txt[238]) {
  114.                     $markers = $markers . 'gender="1"';
  115.                 } elseif ($marker['gender']['name'] == $txt[239]) {
  116.                     $markers = $markers . 'gender="2"';
  117.                 } else {
  118.                     $markers = $markers . 'gender="0"';
  119.                 }
  120.  
  121.                 $markers = $markers . ' label="' . $marker['name'] . '" html="'. $datablurb . '" />';
  122.  
  123.                 echo $markers;
  124.         }
  125.     }
  126.     echo '
  127.     </markers>';
  128.  
  129.     // Ok we should be done with output, dump it to user...
  130.       obExit(false);
  131. }
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#7: Dec 30 '07

re: null or not an object error in IE works perfectly in Firefox


And the final part:
Expand|Select|Wrap|Line Numbers
  1. function ShowKML () {
  2.       global $db_prefix, $context, $scripturl, $txt, $modSettings, $user_info, $mbname, $themeUser, $memberContext;
  3.  
  4.     // Are we allowed to view the map? Keep in mind here we should be a guest unless user is in IE!
  5.     isAllowedTo('googleMap_view');
  6.  
  7.     // If it's not enabled, die.
  8.     if (empty($modSettings['xmlnews_enable']))
  9.         obExit(false);
  10.  
  11.     // This is an kml file, its like an XML file...
  12.     ob_end_clean();
  13.     if (!empty($modSettings['enableCompressedOutput']))
  14.         @ob_start('ob_gzhandler');
  15.     else
  16.         ob_start();
  17.  
  18.     // Lets make sure its sent as KML
  19.     header('Content-type: application/keyhole;');
  20.  
  21.     // It will be called ourforumname.kml
  22.     header('Content-Disposition: attachment; filename="' . $mbname . '.kml"');
  23.  
  24.     // Load the data up, and seeing how its google earth, lets just send everything.
  25.     // If we get complaints about this, then we shall have to figure out how to limit it.
  26.     $request = db_query("
  27.     SELECT *
  28.     FROM {$db_prefix}members
  29.     WHERE latitude IS NOT NULL AND longitude IS NOT NULL
  30.     ", __FILE__, __LINE__);
  31.  
  32.     //Ok this is block of code takes care of the entire load all member data into $memberContext on per # basis
  33.     $temp = array();
  34.     while ($row = mysql_fetch_array($request, MYSQL_ASSOC))
  35.         $temp[] = $row['ID_MEMBER'];
  36.     loadMemberData($temp);
  37.     foreach ($temp as $v)
  38.         loadMemberContext($v);
  39.  
  40.        // Seeing how SMF 1.0 uses $themeUser and SMF 1.1 uses $memberContext, lets just make our own now?
  41.     if (isset($memberContext))
  42.         $data = $memberContext;
  43.     elseif (isset($themeUser))
  44.         $data = $themeUser;
  45.  
  46. echo '<?xml version="1.0" encoding="UTF-8"?>
  47.     <kml xmlns="http://earth.google.com/kml/2.0">
  48.     <Folder>
  49.         <name>' . $mbname . '</name>
  50.         <open>0</open>';
  51.     if (isset($data)) {
  52.     // Assuming we have data to work with...
  53.         foreach ($data as $marker) {
  54. echo '
  55.         <Placemark>
  56.             <description>
  57.                 <![CDATA[';
  58. echo '
  59.                 <table class="googleMaps" border="0" style="white-space: nowrap;">
  60.                     <tr>
  61.                         <td style="white-space: nowrap;" align="left"><a href="' . $marker['online']['href'] . '"><img src="' . $marker['online']['image_href'] . '" alt="' . $marker['online']['text'] .'" class="avatar" border="0" /></a> <a href="' . $marker['href'] .'">' . $marker['name'] . '</a></td>
  62.                         <td rowspan="3">' . $marker['avatar']['image'] . '</td>
  63.                     </tr><tr>
  64.                         <td style="white-space: nowrap;">' . $marker['title'] . '</td>
  65.                        </tr><tr>
  66.                         <td style="white-space: nowrap;" align="center">
  67.                             ' . $marker['icq']['link'] . '
  68.                             ' . $marker['aim']['link'] . '
  69.                             ' . $marker['yim']['link'] . '
  70.                             ' . $marker['msn']['link'] . '
  71.                         </td>
  72.                     </tr><tr>
  73.                         <td style="white-space: nowrap;" colspan="2" align="left">';
  74.                 if (($marker['website']['url'] != '') && ($marker['website']['title'] != ''))
  75.                     echo '<a href="' . $marker['website']['url'] . '">' . $marker['website']['title'] . '</a>';
  76. echo '                    </td>
  77.                     </tr><tr>
  78.                         <td style="white-space: nowrap;" colspan="2" align="left">' . $marker['blurb'] . '</td>
  79.                     </tr>
  80.                 </table>';
  81. echo '
  82.                 ]]>
  83.             </description>
  84.             <name>' . $marker['name'] . '</name>
  85.             <LookAt>
  86.                 <longitude>' . $marker['googleMap']['longitude'] . '</longitude>
  87.                 <latitude>' . $marker['googleMap']['latitude'] . '</latitude>
  88.                 <range>15000</range>
  89.             </LookAt>
  90.             <styleUrl>root://styles#default+icon=0x304</styleUrl>';
  91. /* This does not appeal to me right now...
  92.             if ($modSettings['googleMapsPinGender']) {
  93. echo '
  94.             <Style>
  95.                 <IconStyle>
  96.                     <color>';
  97.                     if ($marker['gender']['name'] == "Male") {
  98.                         echo 'ffff6464';
  99.                     } elseif ($marker['gender']['name'] == "Female") {
  100.                         echo 'ff6464ff';
  101.                     } else {
  102.                         echo 'ff64ff64';
  103.                     }
  104. echo '                </color>
  105.                 </IconStyle>
  106.             </Style>';
  107.             }
  108. */
  109.  
  110. echo '
  111.             <Point>
  112.                 <extrude>1</extrude>
  113.                 <altitudeMode>absolute</altitudeMode>
  114.                 <coordinates>' . $marker['googleMap']['longitude'] . ',' . $marker['googleMap']['latitude'] . ',8000</coordinates>
  115.             </Point>
  116.         </Placemark>';
  117.         }
  118.     }
  119.  
  120. echo '
  121.     </Folder>
  122. </kml>';
  123.     // Ok done, should send everything now..
  124.     obExit(false);
  125. }
  126. ?>
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#8: Dec 30 '07

re: null or not an object error in IE works perfectly in Firefox


Welcome to TSDN!
Quote:

Originally Posted by crazyhorse80

I'm working on a piece of code... I can't get it work with IE, but in FF all is fine...
I think the problem is what you're talking about here, but I can't understand what to do with my code...

Phew! A lot of code to decipher! So, is that the error that you're getting (null or not an object)? Which line does it occur on?
Newbie
 
Join Date: Dec 2007
Posts: 6
#9: Dec 30 '07

re: null or not an object error in IE works perfectly in Firefox


The error occours on line 147 of the first chunk of code... But I'm realizing it could be related to the header of the XML file created by function on line 1 of the second chunk... I've inserted a test point and IE goes in Quirk Mode, so I think it's not recognizing any XML to process in that file... FF goes straight like a train!
Can you help me with this?
Bye and thanks for your greetings,
PS

EDIT: I think I must add this:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2.   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4.  
To the XML page created by function but I dunno how to do it...
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#10: Dec 31 '07

re: null or not an object error in IE works perfectly in Firefox


Check if responseXML is correct by alerting it. Is it as you expect it to be?

It's an XML document, so the XML prolog that you already have should be fine.
Newbie
 
Join Date: Dec 2007
Posts: 6
#11: Dec 31 '07

re: null or not an object error in IE works perfectly in Firefox


I can't understand what I have to do... Can you post the code? I'm not a PHP programmer, I just took that code and trying to make it work...
Tnx,
PS

EDIT: I found this link
http://dean.edwards.name/weblog/2006/04/easy-xml/
It has an interesting chunk of code (the last one); could you help me arranging it to be suitable for my function?
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#12: Dec 31 '07

re: null or not an object error in IE works perfectly in Firefox


Between lines 145 and 147, add an alert: alert(xmlDoc). Is it the expected XML?
Newbie
 
Join Date: Dec 2007
Posts: 6
#13: Dec 31 '07

re: null or not an object error in IE works perfectly in Firefox


This is what it does with FireFox:


???

And this is with IE:



But the best thing is that now, when I click OK in the alert box with IE, the code works as it is expected to do! What could be then? Timings problems? How could then I solve?
Tnx,
PS
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#14: Dec 31 '07

re: null or not an object error in IE works perfectly in Firefox


Quote:

Originally Posted by crazyhorse80

But the best thing is that now, when I click OK in the alert box with IE, the code works as it is expected to do! What could be then? Timings problems? How could then I solve?

That's strange. The ready state is already 4, so the alert shouldn't make a difference. If you check the documentElement, is that also an object?

One other thing, for responseXML to work, the mime-type should be "text/xml". You have set it to "application/xml". I don't know if that makes a difference.
Newbie
 
Join Date: Dec 2007
Posts: 6
#15: Dec 31 '07

re: null or not an object error in IE works perfectly in Firefox


Quote:

Originally Posted by acoder

That's strange. The ready state is already 4, so the alert shouldn't make a difference. If you check the documentElement, is that also an object?

Yes it is.

Quote:
One other thing, for responseXML to work, the mime-type should be "text/xml". You have set it to "application/xml". I don't know if that makes a difference.
I did already change it...

But now it comes the unbelievable thing:
I've just removed the alert(XmlDoc); and all is working fine even with IE... I'm going mad! I was trying to get it working for a week, and now it works by its own??? Too bad... Ah, I've empty browser cache, cookies and all temp files every time I tried something new...
So I can say problem solved... Thank you very very much!
Bye,
PS
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#16: Dec 31 '07

re: null or not an object error in IE works perfectly in Firefox


It must've been something else that you changed.

Anyway, glad to hear that you got it working. Post again if you have any more JavaScripting problems and someone should be at hand to solve them.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,571
#17: Dec 31 '07

re: null or not an object error in IE works perfectly in Firefox


I don't know if it's related but a post above made me wonder if the OP is aware that IE does not recgonize XHTML.
Newbie
 
Join Date: Dec 2007
Posts: 6
#18: Dec 31 '07

re: null or not an object error in IE works perfectly in Firefox


I can't understand... What does OP stands for?
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,571
#19: Dec 31 '07

re: null or not an object error in IE works perfectly in Firefox


"Original Poster" .
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#20: Dec 31 '07

re: null or not an object error in IE works perfectly in Firefox


Quote:

Originally Posted by drhowarddrfine

I don't know if it's related but a post above made me wonder if the OP is aware that IE does not recgonize XHTML.

I don't think the original problem had anything to do with XHTML. That was answered by the OP himself. IE does not set event handlers (onchange, onclick, etc.) with setAttribute unlike other browsers (tell me something new!). Are you talking about post #9 here?
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,571
#21: Jan 1 '08

re: null or not an object error in IE works perfectly in Firefox


Quote:

Originally Posted by acoder

Are you talking about post #9 here?

Yes, that's what caught my eye.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#22: Jan 1 '08

re: null or not an object error in IE works perfectly in Firefox


Quote:

Originally Posted by drhowarddrfine

Yes, that's what caught my eye.

It was unnecessary anyway - it wasn't XHTML, just XML.
Reply