Deleting a directory when clicked on a hyperlink w

2019-03-04 02:05发布

问题:

This isn't working:

 Response.Write("<a href=view.aspx?type="+Content+"onclick=\"Delete('"+f+"')\"> DELETE </a>");


  <script language="javascript" type="text/javascript">

        function Delete(path) {
        path1 = unescape(path);
        var myObject = new ActiveXObject("Scripting.FileSystemObject");
        var myFolder = myObject.GetFolder(path1);

        myFolder.Delete();

        alert("Welcome");
    }
 </script>

But this worked.

  Response.Write("<a href=view.aspx?type="+Content+"onclick=\"Delete()\"> DELETE </a>");

  <script language="javascript" type="text/javascript">

        function Delete() {

        alert("Welcome");
    }
 </script>

I tried with onclick for Delete() to get just ALERT it worked well. But it isn't working when add the parameters.Can you help me please.Trying for this from long time please.

回答1:

First of all, \u is escpae code for a hex digit. So better re-format it.

Second, href=view.aspx?type=notes is not a valid html syntax too. Double quotes please.

Third, please put some code to check if your javascript variables (myObject,myFolder) are valid (not null) before invoke any method against them.