Posts

Showing posts from January, 2006

JavaScript : HTTP Get

I would like to grab http://www.yahoo.com/ website by JavaScript. I found the JavaScript library,
"request.js" (XmlHttpRequest Wrapper) from http://adamv.com/dev/. Demo here!



This is my JavaScript example to grab web page from yahoo.com
<script src="request.js"></script>

<span id="HttpContents">NO DATA</span>

<script>

Http.get({

 url: "http://www.yahoo.com/",

 callback: getHttpContents,

 cache: Http.Cache.GetNoCache

}, [HttpContents]);



function getHttpContents(result,HttpContents){

 if (result.status==Http.Status.OK){

  HttpContents.innerHTML = result.responseText;

 } else {

  HttpContents.innerHTML = "An error occurred (" + result.status.toString()
+ ").";

 }

}

</script>


just Developer note...

JavaScript Sleep() 2

I found an article Implementing Wait in JavaScript, wrote by Josef Betancourt


This is his example


function Pause(duration, busy){
this.duration= duration * 1000;
this.busywork = null;
this.runner = 0;
if (arguments.length == 2) {
this.busywork = busy;
}
this.pause(this.duration);
}

Pause.prototype.pause = function(duration){
if ( (duration == null) || (duration < 0)){
return;
}
var later = (new Date()).getTime()+duration;
while(true){
if ((new Date()).getTime() > later){
break;
}
this.runner++;
if (this.busywork != null) {
this.busywork(this.runner);
}
} // while
} // pause method



to use


function showme(progIndex){
window.status= "progress: " + progIndex;
}
var p = new Pause(5, showme);



visit Implementing Wait in JavaScript page.

JavaScript Sleep()

How do I pause execution in JavaScript?

How do I pause execution in JavaScript?

Is there a wait statement in JavaScript?

Is there a sleep method to pause execution?

Is there a sleep method to pause execution?




I found a useful article how do I pause execution in JavaScript to description how to delay JavaScript process.



some example

function pause(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}




function pause(numberMillis) {
var dialogScript =
'window.setTimeout(' +
' function () { window.close(); },
' + numberMillis + ');';
var result =


// For IE5.
window.showModalDialog(
'javascript:document.writeln(' +
'"< script>' + dialogScript + '<' + '/script>")');


/* For NN6, but it requires a trusted script.
openDialog(
'javascript:document.writeln(' +
'"< script>' +…