Results 1 to 7 of 7

Thread: loading html in DIV tag

  1. #1
    Join Date
    May 2008
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default loading html in DIV tag

    i am trying to load a html page in div.. its working fine in local machine, but when i upload to server its working fine in IE7 , but its not working in IE6 what would be problem.. below given is the script i am using...

    Please help me in solving the issue.. i Need to deliver the product today help me to solve the issue.. thanks in advance.. ravimmrk@gmail.com

    Code:
    function loadXmlHttp(url, id) {
    var f = this;
    f.xmlHttp = null;
    
    if (window.XMLHttpRequest&&!f.ie||/^http/.test(window.location.href))
    f.xmlHttp = new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari, others, IE 7+ when live - this is the standard method
    else if (/(object)|(function)/.test(typeof createRequest))
    f.xmlHttp = createRequest(); // ICEBrowser, perhaps others
    else {
    f.xmlHttp = null;
    
    
    }
    if(f.xmlHttp != null){
    f.el = document.getElementById(id);
    f.xmlHttp.open("GET",url,true);
    f.xmlHttp.onreadystatechange = function(){f.stateChanged();};
    f.xmlHttp.send(null);
    }
    
    else alert('Your browser does not support AJAX!'); // substitute your desired request object unsupported code here
    }
    loadXmlHttp.prototype.stateChanged=function () {
    if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href)))
    	this.el.innerHTML = this.xmlHttp.responseText;
    	
    }
    
    function loadpage (url, id){
    	
    	new loadXmlHttp(url, id)
    
    	}
    Last edited by jscheuer1; 05-27-2008 at 02:52 PM. Reason: add code tags

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I don't know for sure where you got that code, but it looks like it came from:

    http://www.dynamicdrive.com/forums/s...849#post143849

    If so (or even if you got it elsewhere), you aren't playing with a full deck, use the full code. Also, if the IE 6 that you are testing in is a 'stand alone' version of IE 6, even if it is not, it may have key elements in it disabled, thus not allowing it to perform a request.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Quote Originally Posted by jscheuer1 View Post
    I don't know for sure where you got that code, but it looks like it came from:

    http://www.dynamicdrive.com/forums/s...849#post143849
    Nice script. However, when my external URL contains foreign characters (like 'thé'), I get 'th?'. This is a general ajax-problem that I cannot solve.
    ---
    Arie.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by molendijk View Post
    Nice script. However, when my external URL contains foreign characters (like 'thé'), I get 'th?'. This is a general ajax-problem that I cannot solve.
    ---
    Arie.
    I'm not positive I understand, at first I thought you meant the URL, in which case you could just escape it or URLencode it. But after rereading your post, I think you mean characters on the external page. For that, you must make sure that the server is serving the page with the proper Content-Type charset. Most default to UTF-8 for AJAX requests regardless of any meta-tag on the external page. However the server itself may be configured to use iso-8859-1 or whatever is required. The .htaccess file may be used for this, as can the server's main configuration panel. I don't have the specifics on either, but you can Google how this is done with .htaccess (requires authorization and capability), and how a particular server can be configured in its panel would vary somewhat from server to server.

    Although, for just a few characters on a page, you may be able to use their entities, like:

    Code:
    é
    for é.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Thanks John,
    Yes, I know about the entities corresponding to the foreign characters. But that solution requires too much 'extra work' in certain cases.
    As for the server's configuration: I'm trying to solve this matter for a friend who doesn't have access to it (his site is a hosted one).
    The easiest solution would be a script that automatically replaces the foreign characters with the corresponding entities in the external page, I guess.
    The strange thing is that the problem does not arise when we use a java-based script like the following (but that doesn't work in IE):
    Code:
    <SCRIPT type="text/javascript">
    var data = new Array();
    var i = 0;
    var datafile = window.location.href.substring(0,
    window.location.href.lastIndexOf("/") + 1) + "test.html";
    var url = new java.net.URL(datafile);
    var connect = url.openConnection();
    var input = new java.io.BufferedReader(
    new java.io.InputStreamReader(
    connect.getInputStream()));
    var aLine = ""
    while((aLine = input.readLine())!= null) {
    data[i++] = aLine;
    }
    </SCRIPT>
    
    <SCRIPT type = "text/javascript">
    var temp = ""
    for (var j = 0; j < data.length ; j++)
    temp += data[j] + "<br>";
    document.write(temp);
    </SCRIPT>
    .
    ---
    Arie.
    Last edited by molendijk; 05-28-2008 at 05:52 PM. Reason: Correction

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Another possibility would be, if the server has PHP or asp, to put a Content-Type charset header on the page in that language (PHP or asp) and rename it to .php or .asp - I know that this can be done with PHP, not sure about asp - though the two can usually do the same (basic) things as each other, it's just the syntax that varies.

    I don't know anything (much) about java, but wouldn't that require a java plug in? If so, the way to create a java object in IE is with ActiveX (not sure of the exact syntax), so you would have to test and branch for that most likely to get your java code to execute in IE.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Non-IE browsers have exposed the JAVA objects java and Packages. That's why the above script works in those browsers. IE doesn't have that functionality. It creates java in its own way using ActiveX.
    Anyhow, I think I might be able to solve the problem using a replace-function for foreign characters. I'm working on it. I'll let you know. Thanks so far.
    ===
    Arie.

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
  •