
HTTPProvider Object
269
Sample HTTPProvider script
//**********************************************//
// ActiveScripting example (JScript)
//**********************************************//
// This script contacts the site specified by the user URL,
// copies its source code and displays the page in the internal
// browser of the application
//**********************************************//
function Main (){
var sDocName;
var sSource;
var sMessage;
with (Application){
if (HTTPProvider.State == 0){
// Set the URL property of HTTPProvider Object.
HTTPProvider.URL = InputBox(VersionText, "Please Enter the URL.",
"http://www.yahoo.com");
// Perform HTTP Get Request
HTTPProvider.Get();
sSource = ’’;
if (HTTPProvider.ReasonPhrase == "OK") // Check if the requested
URL can be displayed
sSource = HTTPProvider.ReceivedStreamAsString; //Save the page
source into the string
else{
sSource = ’<font size="+2" color="#0000ff" >’ //If the page
cannot be displayed, post error message and show a reason.
sSource = s ’The request could not be completed:
<br><br><li>’
sSource = s HTTPProvider.Reason ’.</font></
li>’;
}
sMessage = "The source of the requested page has been copied
successfully,\n";
sMessage = sM ’the page now will be displayed ’;
sMessage = sM ’in the browse window of \n’ + Versi
’!’;
MessageBox (sMessage, VersionText, 0);
}
else{
sSource = ’You are not connected to Internet properly, ’;
sSource = s ’please check the connection and try again’;
}
MessageBox("Some images may not be downloaded properly!","Warning!",0);
NewDocument (false); // Initialize a new document.
ActiveDocument.InsertText(sSource, false); // Insert the received
source code into new document.
CurrentView = 2;// Change to the browse mode.
}
}
Summary of Contents for COLDFUSION STUDIO 5-USING COLDFUSION 5...
Page 18: ...xviii About This Book...
Page 26: ...8 Chapter 1 Setting Up the Product...
Page 42: ...24 Chapter 2 Configuring Browsers and Servers...
Page 60: ...42 Chapter 3 Exploring the Workspace...
Page 100: ...82 Chapter 6 Editing Pages...
Page 126: ...108 Chapter 7 Using Web Development Languages...
Page 212: ...194 Chapter 13 Customizing the Development Environment...
Page 320: ...302 Glossary...