The src property of img can't call the function directly, can it?

an old project made by jsp a long time ago asked me to write a general method because I put all the pictures in a fixed place, and all the img tags called that method and then loaded the images.
because I was relatively lame at that time, I found a strange way on the Internet:

  https://whatwg-cn.github.io/h., the specification mentions that the  src  attribute cannot execute the js script, and now I don"t have the latest code of that project, and I don"t know why the boss wrote this to solve the interface problem twice. Is it difficult to  src= "getUrl (this)"  to prevent the execution of  src , so  src  originally needed to remove the interface but was blocked? 

Mar.22,2021

of course not. Will be regarded as URL.

is probably the URL 404, so if something goes wrong, call onerror.

For the problem of calling

twice before, you can type out the error. For example, when setting up src, there was a problem with the onerror processor for the first time.


if functions cannot be used in src, will they be treated as strings? Then the error is bound to be reported, and the onerror is executed.

Menu