Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reading file content

    The questions "Can I read a file... " show up on the regular basis. The answer to accessing files on the same domain is the XMLHTTP object. Following is a simple wrapper that accounts for differences in Gecko and IE5.5+ implementation and returns the content of a file in a string, or null if an error occured:
    Code:
    function getFile(filename)
      { oxmlhttp = null;
        try
          { oxmlhttp = new XMLHttpRequest();
            oxmlhttp.overrideMimeType("text/xml");
          }
        catch(e)
          { try
              { oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
              }
            catch(e)
              { return null;
              }
          }
        if(!oxmlhttp) return null;
        try
          { oxmlhttp.open("GET",filename,false);
            oxmlhttp.send(null);
          }
        catch(e)
          { return null;
          }
        return oxmlhttp.responseText;
      }
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    useful information... thanks
    Last edited by swmr; 03-30-2004 at 06:42 AM.
    hmm... ?

  • #3
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    which browsers have this object? is it just windows?
    life without death would get kinda monotonous after a while, eh?

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Hmm, seems a lot like my importing file as string script, some time back.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Did not know you posted a similar script, liorean.
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #6
    New to the CF scene
    Join Date
    May 2003
    Location
    Shanghai, China
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this function doesnot work in my mozilla 1.6a. y?
    could you tell me when can i get the reference of the object "XMLHttpRequest" in mozilla version

    and as i know MSXML2.XMLHTTP is not available at IE 5.0 if some one has not installed MSXML2 parser or MDAC(which updates the MSXML) yet.

    here is a version list of msxml:
    http://www.perfectxml.com/msxmlRef.asp

    and i prefer startDownload method
    of ie default behaviors
    http://msdn.microsoft.com/workshop/a...asp?frame=true
    excuse my poor english~

  • #7
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Been supported since before 1.0 version, IIRC.
    <http://unstable.elemental.com/mozill...tpRequest.html>,
    <http://unstable.elemental.com/mozill...t-members.html>,
    <http://www.mozilla.org/newlayout/xml/>,
    <http://www.mozilla.org/xmlextras/>

    My version uses an older MSXML than this, maybe that works in ie5.0w.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #8
    Regular Coder
    Join Date
    Aug 2004
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hay, i'm using this script for importing different pieces of html in my page. but, in IE only, sometimes (i dont know under what circumstances) when i import a FORM the script crashes entire explorer (including taskbar and background of windows). any ideas what could do that?


  •  

    LinkBacks (?)


    Posting Permissions

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