开发者

saving a dynamically created page by Jquery

<html>
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").after(" Hi .");
});
});
</script>
</head>

<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button&g开发者_Go百科t;
</body>
</html>

after i clicked the "Click me button" 5-6 times.. NEW HTML that is generated . isnt it ?

So I want to save that new generated HTML in a file through ASP.Net or PHP

Any idea's How to do it ?


Copy the body contents into a textarea and submit it in a form.

var css = $("style:first").html();  //this will ver the first style tag
$("#myCssTextarea")
         .val("<style type='text/css'>"+css+"</style>");

var html = $("body").html();
$("#myTextarea")
         .val(html)
         .parents("form")
         .submit();

HTML

<form action="" method="post">
     <textarea id="myTextarea" name="content" style="width:0; height:0;"></textarea>
     <textarea id="myCssTextarea" name="cssContent" style="width:0; height:0;"></textarea>
</form>

PHP

if($_POST["content"]){
     $file = fopen('mypage.html', 'w');
     fwrite($file, $_POST["content"]);
     fwrite($file, $_POST["cssContent"]);
     fclose($file);
}

UPDATE Added css storing code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜