SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript running with legacy ASP and Firefox

    Hey all - I have some JavaScript that runs beautifully in IE, but while writing for Firefox I'm running into some strange loops. When I intentionally break the loop with some code, I can see that Firefox isn't finding the same variables that IE found.

    I'm writing for a Microsoft VE mapping solution. We ran tests earlier last month, when just writing for simple HTML pages. No problems at all (with IE & FF). Now that the design has incorporated legacy ASP to build a table data grid that resides next to and uses that same XML data as the VE map, the Firefox code is . . . well, I don't know. IE behavior is perfect, just as expected.

    Is the FF browser loading the Javascript and ASP at different times than the IE browser? Of course the ASP would be server-side and load initially but then with the spaghetti HTML code and the JavaScript thrown in does anyone know if FF treats things in a different manner than IE and would the JavaScript for the FF need to be placed somewhere other than in the <head> tag?

    Any help or expertise on this would be greatly appreciated. Thanks . . .
    Rob

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you using xml data islands? (<xml> tags inside the html, see http://www.w3schools.com/xml/xml_data_island.asp) I'm pretty sure they are internet explorer only.

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, no data islands.

    The XML files are being called from another directory. Both the JavaScript and the ASP then iterate through the rows of data and extract what they need.

  4. #4
    SitePoint Evangelist
    Join Date
    Mar 2006
    Location
    Sweden
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IE's and FF's javascript implementations are quite different, especially when it comes to handling events. It would be easier to know if you gave us a link to the application.

    I wouldn't say that it's necesserily IE that is working perfectly, it's just that the code is written for IE. IE has given me _a lot_ more headaches than Firefox has.

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately, what I'm working on is behind a firewall. Let me try and figure out a way to get something outside so you can take a look.

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The XML files are being called from another directory. Both the JavaScript and the ASP then iterate through the rows of data and extract what they need.
    So how is this being done? Are you opening the XML via javascript, ie XMLHTTP?

  7. #7
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually the XML get loaded server-side via the ASP. I have then been populating a hidden text file with the value. I used to just just take the ASP variable and then call that variable inside of the Javascript. Anyway, currently I then just load the XML in IE with:

    var asp_Region = document.getElementById("sRegion").value;

    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async = false;
    xmlDoc.load("bookearly_" + asp_Region + ".xml");
    xmlObj = xmlDoc.documentElement;

    In Firefox it's a little more convulted. Like this . . .

    function getBrowser()
    {
    if (navigator.userAgent.indexOf("MSIE") != -1)
    {
    g_isIE = true;
    if (navigator.userAgent.indexOf("MSIE 7") != -1)
    g_isIE7 = true;
    }
    else if (navigator.userAgent.indexOf("Firefox") != -1)
    g_isFirefox = true;
    initMap_ff();
    }

    then initally in initMap_ff() is:

    var asp_Region = document.getElementById("sRegion").value;
    xmlDoc = document.implementation.createDocument("","",null);
    xmlDoc.load("bookearly_" + asp_Region + ".xml");

    the initial error is:
    document.getElementById("sRegion") has no properties

  8. #8
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Assuming that there is an input field with id= sRegion then it should be ok.

    Are you calling this javascript from the onload of the window/document?

    Maybe if not, the input field doesn't exist yet?

  9. #9
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, I have been using the <body onload="GetMap();"> to load the JavaScript. It's the MS VE Map SDK loading method and I've been using that load method for other trial solutions. It seemed (past tense) to work fine.

    This is the very heart of my question. More detail. In the <head> tag is this:

    <script type="text/javascript" src="initMap.js"></script>
    <script type="text/javascript" src="addCustomPushpin.js"></script>
    <script type="text/javascript" src="sorttable.js"></script>
    <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>

    the GetMap() function is in the initMap.js file.
    the <body> tag is immediatle following. Right after that are some ASP delimiters with the code that has the variable containing the XML file name.

    <&#37;
    dim strRegionBE: strRegionBE = "Caribbean"
    %>
    a bunch of other ASP also, and then . . . the text hidden fields:

    <form ID="Criteria" METHOD="GET" ACTION="">
    <input TYPE="HIDDEN" ID="sRegion" NAME="sRegion" VALUE="<%= lcase(strRegionBE) %>">
    <input TYPE="HIDDEN" ID="sLocation" NAME="sLocation" VALUE="<%= strLocationBE %>">
    </form>

    the text fields are in the same place for both the IE and FF javascript code to read. Yet the FF says that "document.getElementByID("sRegion") has no properties". The text field is populated when the IE code runs through it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •