- (function () {
- var YUD = YAHOO.util.Dom, YUE = YAHOO.util.Event;
- dataRequest = {
- _doc: document,
- cfg: {
- proxyUrl: 'proxy.html'
- }
- };
- dataRequest.send = function (sUrl, fnCallBack) {
- if (!sUrl || typeof sUrl !== 'string') {
- return;
- }
- sUrl += (sUrl.indexOf('?') > 0 ? '&' : '?') + 'windowname=true';
- var frame = this._doc.createElement('iframe'), state = 0, self = this;
- this._doc.body.appendChild(frame);
- frame.style.display = 'none';
- var clear = function () {
- try {
- frame.contentWindow.document.write('');
- frame.contentWindow.close();
- self._doc.body.removeChild(frame);
- } catch (e) { }
- };
- var getData = function () {
- try {
- var da = frame.contentWindow.name;
- } catch (e) { }
- clear();
- if (fnCallBack && typeof fnCallBack === 'function') {
- fnCallBack(da);
- }
- };
- YUE.on(frame, 'load', function () {
- if (state === 1) {
- getData();
- } else if (state === 0) {
- state = 1;
- frame.contentWindow.location = self.cfg.proxyUrl;
- }
- });
- frame.src = sUrl;
- };
- })();
- //该片段来自于http://www.codesnippet.cn/detail/231020136620.html
来源: http://www.codesnippet.cn/detail/231020136620.html