A problem window.open with a xml document in IE

Discussion in 'JavaScript' started by yz_nk, May 24, 2010.

  1. #1
    I located a xml document with Javascript's window.open, but I cannot access the new window after the document loaded:

    mywin = window.open("_Blank", "mywin");
    alert (mywin.closed);
    mywin.location = "http://127.0.0.1:8899/mydoc.xml";
    alert (mywin.closed);

    I get a "false" at the first alert and a "true" at the second alert. I don't know why this happens. If I locate a html document, the two alert was all "false".
     
    yz_nk, May 24, 2010 IP
  2. flexdex

    flexdex Peon

    Messages:
    104
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The correct syntax should be:
    
      mywin = window.open("","_blank", "mywin");
    
    Code (markup):
    Anyway, i doubt that this is the issue, so two other problems could be the case:
    1. test if the .xml document on that port could be accessed from that place
    2. maybe the .xml file runs with a different file handler, so the browser try to save it or open it with a tool like xmlspy, notepad++ or anything else

    Regard
     
    flexdex, May 25, 2010 IP
  3. yz_nk

    yz_nk Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I tried to open a local xml file such as "file:///d:/temp/./test.xml", the file load correct, but got the same result. But If I open a window with the same name after loading the xml document, I can get the correct handle:

    mywin = window.open("", "_Blank", "mywin");
    alert (mywin.closed);
    mywin.location = "http://127.0.0.1:8899/mydoc.xml";
    alert (mywin.closed);
    mywin = window.open("", "", "mywin");
    alert (mywin.closed);


    After the second window.open, I can use the window.

    I suppose the reason as below:
    1. As describes in some Javascript documents, when a new page is loading, window object is cleared as the page is unlaoded.

    2. Usually, when a html page is loaded, It use the same window object, and the window is opened again. so we can use a variable to store the window object and use it in global.

    3. But when a xml document is loaded, IE use a new ActiveXObject to load xml document, just as we do the same thing with Javascript. The ActiveXObject may create a new window object with the same name as the old one, then the old one is discarded!

    I don't know whether it is correct. Any one should make it clear and solve the problem?
     
    yz_nk, May 25, 2010 IP
  4. flexdex

    flexdex Peon

    Messages:
    104
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It should be really "_blank"
     
    flexdex, May 26, 2010 IP