XMLHttpRequest to get HTTP response from remote host

前端 未结 4 2021
礼貌的吻别
礼貌的吻别 2021-01-02 06:24

Why the following code Based on Mozilla example does not work? Tried with Firefox 3.5.7 & Chrome.



        
4条回答
  •  猫巷女王i
    2021-01-02 06:47

    Security issue no?

    Presumably firefox is preventing the local file from talking to a remote host?

    Scouting round the net - found this. Try adding this to the start of your script:

    try {
      netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
    } catch (e) {
      alert("Permission UniversalBrowserRead denied.");
    }
    

    Can't guarantee this'll work; because ultimately what you're trying to do is enter a security hole that browsers have been specifically coded to have plugged up (cross-domain requests).

    There are some special scenarios where it can be switched on, though, usually at the user's discretion.

提交回复
热议问题