Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save source to file

Status
Not open for further replies.

Nebooaw

Programmer
Jun 1, 2001
142
GB
Hi, does anyone know if it is possible to select a button on a webpage to create a new page with the current pages source and save it to a new file?

Kindest Regards.
 
In IE, menu Display -> Source

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for replying, i want to be able to do this automatically and save it to a file - all with vbscript or javascript.

Should of been a bit clearer in my post.

Regards.
 
Can you create a macro in I.E
I dont know for sure if it is possible , but if it is , then thats what you need ?

-
mobajwa

After the game ,the king and the pawn , both go in the same box.
 
Still having problems with this. Can anyone post an example as im out of ideas?

Kindest regards.
 
Code:
function displayCode(page_to_display)

set fsObj = CreateObject("Scripting.FileSystemObject")
set fileObj = fsObj.OpenTextFile(server.mappath(page_to_display),1,false)

do while not fileObj.AtEndOfStream

 
response.write server.htmlencode(fileObj.readline)  &  "<br>"

loop

fileObj.Close
set fileObj = NOTHING
set fsObj = NOTHING

end function

All hail the INTERWEB!
 
oops, didn't mean to hit submit. Just use FSO to save that to an output file.

Code:
					'msgBox oCmd.CommandText
					'create file for debug
					Dim objFileSystem, objOutputFile
					Dim strOutputFile
					'generate a filename base on the script name
					strOutputFile = "something.txt"

					Set objFileSystem = CreateObject("Scripting.fileSystemObject")
					Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)
		
					objOutputFile.WriteLine server.htmlencode(fileObj.readline)  &  "<br>"
					objOutputFile.Close
	
					Set objFileSystem = Nothing
	
					 
                    'end create file

You might have to troubleshoot that code, I didn't test any of it.

All hail the INTERWEB!
 
Thanks for the example, will try it out this morning and let you know how i get on.

Kindest regards.
 
Actually, I see an error in that code already...I didn't call the function correctly.



Code:
'msgBox oCmd.CommandText
'create file for debug
Dim objFileSystem, objOutputFile
Dim strOutputFile
'generate a filename base on the script name
strOutputFile = "something.txt"

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)
        
objOutputFile.WriteLine displayCode("pageTodisplay.asp")
objOutputFile.Close
    
Set objFileSystem = Nothing
    
                     
'end create file

All hail the INTERWEB!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top