السلام عليكم
انا حاليا اقوم بتعلم لغة html و ما زلت في طور بدايتي
و لكن صادفتني مشكلة حول كيفية تضمين صفحة html في صفحة اخرى
اي لدي الكود هذا عبارة عن simple login , الذي يعتمد على ادخال اسم المستخدم و الباسورد
و اذا كانت البيانات صحيحة يتم فتم الصفحة target.html.
<html>
<head>
<title>
Login page
</title>
</head>
<body>
<h1 style="font-family:Comic Sans Ms;text-align="center";font-size:20pt;
color:#00FF00;>
Simple Login Page
</h1>
<form name="login">
Username<input type="text" name="userid"/>
Password<input type="password" name="pswrd"/>
<input type="button" onclick="check(this.form)" value="Login"/>
<input type="reset" value="Cancel"/>
</form>
<script language="javascript">
function check(form)/*function to check userid & password*/
{
/*the following code checkes whether the entered userid and password are matching*/
if(form.userid.value == "myuser" && form.pswrd.value == "mypass")
{
window.open('target.html') /* opens the target page while Id & password matches*/
}
else
{
alert("Error Password or Username")/*displays error message*/
}
}
</script>
</body>
</html>
لكن انا لا اريد ان يقوم بفتح صفحة خارجية و انما يقوم بتنفيذ الكود الخاص بي في نفس الصفحة بكود جديد .. الذي هو كود html الخاص بي: هذا هو :
<html> <header> <h1>Hello World</h1> </header> <body> <table border=3> <td><tr>my table</tr></td> <td>test1</td> <td>test2</td> <td>test3</td> </table> </body> </html>
ان اقوم بنسخ الكود اعلاه و اضعه السطر (window.open(target.html يعطيني خطأ ..!!
فمل الحل جزاكم الله خيرا