JavaScript src link

1

Good, I have the following code, in a function Javascript ,

function(){           
   var noDataIcon = document.createElement("img");

   noDataIcon.src = "~/Images/delete_database.png";

}

It happens to give me an error in src, can not find the image.

How do I solve this problem?

Thank you

    
asked by anonymous 08.08.2016 / 18:05

1 answer

1
  

How do I solve this problem?

Not using this notation:

"~/Images/delete_database.png";

It is only valid within the server code. Not in client code.

Use instead:

noDataIcon.src = "/Images/delete_database.png";

If the application is in a subdirectory, you may need to handle the address.

    
09.08.2016 / 20:51