Using webpage link as in image element but not responding

Viewed 23

So I am new to HTML. I have a webpage that contains only a picture in its background; with each refresh, a new image is loaded. However, I want to use that webpage link as in the Image element so anyone can use that image in their webpage, I know < iframe > tag can be done for this task but I can not use it, due to some reason.
some what similar to this :http://placeimg.com/640/480/people

 <body id="testing" onLoad="randompicture()">
            <script>
     function randompicture(){
     const i = Math.floor(Math.random() * 5) + 1;
     const path='images/image' +i+ '.png';
     console.log(path)
    document.getElementById("testing").setAttribute("style", "background-image: url(" + path +");background-repeat: no-repeat;background-size: 388px 388px");
               }
       
            </script>
        </body>
1 Answers

http://placeimg.com/640/480/people is a URL to an image.

Which image you get is determined by server-side code.

It is not an HTML document. It is not done with client-side JS.

You cannot use an HTML document as the source URL for an img element or background image.

Related