﻿//取得ID对应的对象
function $(str)
{
  return document.getElementById(str);
}

//删除字符串头尾空格
String.prototype.Trim = function() 
{ 
  return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

//创建XMLHTTP对象
function CreateXMLHttpRequest()
{
  var xmlHttp;

  try
  {
    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
  }
  catch(e)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(e2)
    {
      xmlHttp = false;
    }
  }

  if (!xmlHttp && typeof XMLHttpRequest != "undefined")
  {
    xmlHttp = new XMLHttpRequest();
  }

  return xmlHttp;
}

//同步获取某页面的输出
function GetTextFromUrl(url)
{
  var xmlhttp = CreateXMLHttpRequest();

  xmlhttp.open("GET", url, false);
  xmlhttp.send();
  
  return xmlhttp.responseText;
}

