我有两个不同的页面,mouth.html 和nose.html。我想从mouth.html 中得到一个名字。所以当用户访问nose.html时,它会在nose.html中打印出来自mouth.html的地名。我怎样才能在 Javascript 中做到这一点?
这是mouth.html 中的代码
<h1 class="man" style="clear:both;">{{ moot.name }}</h1>
在nose.html中,我试过了,但它不起作用
<script language="javascript">
$("h1.man").load("mouth.html",function(data){
var value=$(data).find("h1.man").attr("man")
});
</script>
nose.html 中的完整代码
<head>
<script language="javascript">
$.get( 'mouth.html', function( data ) {
var mootName = $(data).text();
// Do something with mootName here
alert(mootName);
});
</script>
</head>
<body>
<form action="." method="POST">
{% csrf_token %}
<div class="post-fed">
<p><label for="id_event_date">Event date:</label><input type="text" name="event_date" id="id_event_date" /><span class="helptext">E.g 2012-01-00.YYYY/MM/DD</span></p>
<p><label for="id_end_date">End date:</label><input type="text" name="end_date" id="id_end_date" /><span class="helptext">E.g. 2012-01-00.YYYY/MM/DD</span></p>
<p><label for="id_event_information">Event information:</label><textarea id="id_event_information" rows="10" cols="40" name="event_information"></textarea><span class="helptext"> E.g. eating etc</span></p>
<p><label for="id_full_name">Full name:</label><input id="id_full_name" type="text" name="full_name" maxlength="100" /></p>
<p><label for="id_e_mail">Email:</label></th><td><input id="id_e_mail" type="text" name="e_mail" maxlength="100" /></p>
<p><label for="id_phone_no">Phone no:</label></th><td><input id="id_phone_no" type="text" name="phone_no" maxlength="100" /></p>
<input type="submit" class="put" value="Send"/>
</form>
</div>
</body>