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>
***********************************
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>
***********************************