Click to See Complete Forum and Search --> : getting page source into file


charles97
08-12-2003, 11:17 AM
Hi everybody,

What I want to do is to get the source code of a page into a file by simply clicking on a button of a top frame.

I made a page were I can view a button in a top frame and a any web page in the bottom frame. called first HTML file bellow

When I click on this button it is supposed to pass the source code to a php file that would take care of creating a file since I red that javascript can't do that (by simple means anyway)

My problem is the definition of the source code in javascript i'm certain there must be a way to pass the text value of the second frame document to the first document form right???

I don't know if i'm close to the solution or far in the field... Someone can help with this??


************* first HTML file *****************************

<html>

<head>
<title>sourcecolector</title>
</head>
<frameset rows="100,*">
<frame name="selectorframe" src="selector.html">
<frame name="contentframe" src="http://www.google.com">
</frameset>
</html>


************* selector.html file *****************************

<html>
<head>
<title>spider</title>
<script language="Javascript">
function sourcetoform(){
//get the html element of the bottom frame
var mainelement = parent.contentframe.getElementsByTagName("html")[0];
//put the source in the form
document.outputtext.contenu.value = mainelement.outerHTML;
//submit the form
document.outputtext.submit();
}

</script>
</head>
<body>
<form name="outputtext" action="filewriter.php" method="post">
<input type="hidden" name="contenu">
<input type="button" value="create file" onclick="sourcetoform()">
</form>
</body>
</html>
***********************************

Jona
08-12-2003, 11:34 AM
You can't view the source of a file cross-server that way, that I'm aware of. I made a script that opens Notepad and includes the source code, but I think it would be simpler to use PHP to get the source, and then use it to do whatever you want to do with it.

[J]ona

charles97
08-12-2003, 12:03 PM
so you can put the source in notepad but not in a html form?
hard to believe.

I would like to see that script.

php is not what i need... i want to be able to browse trough pages and when i find what i want.. i click the button.. would be a really though job to browse sites with cookie and else with php.

Jona
08-12-2003, 12:10 PM
That I'm aware of, you can't do that. When you try to do it cross-server/domain, you usually get a security error, and the script fails to execute. You can see my script at http://geocities.com/god_loves_07/viewsource.html and just remember to put http://server.com/page.html because just putting www won't work.

[J]ona

charles97
08-12-2003, 02:27 PM
Tanks for the link,

I can see what you doing is using the view-source function of the browser... that's not realy what I want to do