Javascript语句不工作…获取'加载资源'错误

javascript statements not working... and getting 'failed to load resource' error

本文关键字:资源 错误 加载 获取 语句 工作 Javascript      更新时间:2023-09-26
<?
echo '<html>
<script language=javascript>
function validate()
{
    alert("validate");
    document.form1.action="validate.php";
    document.form1.submit();
    return false;
}
function del()
{
    alert("delete");
    document.form1.action="delete.php";
    document.form1.submit();
    return false;
}
</script>
<style>
.id
{
    background-image:url("http://localhost/troubleshoot/imges/bg1.jpg");
    background-position:center;
    background-repeat:no-repeat;
    background-size:2000px 2000px;
    border-radius:5px;
}
table
{
    border-radius:5px;
}
.id1
{
    border-radius:5px;
    background-color:DDDDDD;
}
id3
{
    padding-top:5em;
    padding-bottom:5em;
    height:40px;
}
.id2
{
    text-shadow:0px 0px 5px black;
    color:#FFFFDD;  
    font-size:20;
    font-style:bold;
}
</style>
<body> 
<table width=70% align=center>
    <td><img src="http://localhost/troubleshoot/imges/banner.jpg" height=150 width=100% style="border-radius:5px">
</table>
<table width=70% bgcolor=#3E638C align="center" border=0 style="border-radius:5px;" cellspacing=20>
<tr><td align="center"><a href="home.html"><font color=white>Home</a></td>
       <td align="center"><a href="about.html"><font color=white>About Us</a></td>  
       <td align="center"><a href="articles.html"><font color=white>Articles</a></td>
       <td align="center"><a href="work.html"><font color=white>Work</a></td>
       <td align="center"><a href="contact.html"><font color=white>Contact Us</a></td>
</tr></table>';
$c=mysql_connect("localhost","root","");
mysql_select_db("troubleshoot",$c);
$q=mysql_query("select * from clientbugandsol");
$count=mysql_num_rows($q);
echo "<table width=70% align=center border=1 style='border-radius:5px;'>
<tr><td width=100% align=center> <font face=algerian color='#A52A2A'>There are $count bugs received</tr>
<tr><td>";
$i=1;$j=0;
while($s=mysql_fetch_row($q))
{
    echo "<form name=form1 method=post>
<table width=90% bgcolor='#6CDAF5' align=center>
        <tr><th align=left> Bug $i: </tr>
        <tr><td>Username: <td> <input type=text value='$s[0]' name=username> </td></tr>
        <tr><td>User email-id: <td><input type=text value='$s[1]' name=email> </td></tr>
        <tr><td>User Contact-no :<td><input type=text value='$s[2]' name=contactno> </td></tr>
        <tr><td>Bug: <td><textarea rows=5 cols=40 name=bug>$s[3]</textarea></td></tr>
        <tr><td>Bug-Reason: <td><textarea rows=5 cols=40  name=text1>$s[4]</textarea></td></tr>
        <tr><td>Bug-Solution:<td><textarea rows=5 cols=40 name=text2>$s[5]</textarea></td></tr>
        <tr><td>Updated-date:<td><input type=text value='$s[6]' name=date></td></tr>
        <tr><td width=100% align=right colspan=2><input type=submit value='add this bug with main bugs'  OnClick='validate()'>
        <input type=submit name=delete  value='delete this bug' OnClick='del()'></tr>
        </table><br></form>";
}
echo '  
</body>
</html>';
?>
<html>
</html>

加载资源失败。当执行此代码时,在javascript document.form1中。行动行不通....所以它不会重定向到另一个页面。我要澄清的是…

除了html结构的所有问题之外,我怀疑您遇到的根本问题是浏览器找不到delete.php文件,我假设该文件位于此代码来自的文件所在的同一目录中。虽然在服务器上,这种形式的路径相对寻址可以工作,但一般来说,出于安全考虑,浏览器会阻止从主机文件系统加载文件。

改变你的动作,通过你的本地web服务器(即http://localhost/troubleshoot/delete.php)访问delete.php,你应该能够加载文件。