dimanche 3 janvier 2021

Is there any library or code to preview html,js along with media files

i had a image tag in sd.html file like below

    <!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <body>
         <img src="sd.png" />
                 

    </body>
        </html>

i need to show its preview on index.html using iframe. and index.html code is below

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
 
</head>
<body>
    <iframe id="serviceFrameSend"  width="600" height="400" style="background-color: aqua;"  frameborder="0"></iframe>
</body>
<script>
 var contents=document.getElementById('serviceFrameSend');
   

    contents.setAttribute('src','/sd.html');
</script>
</html>

this method cannot work in iframe with image,as its src is path. but there is no such file in the source pane so is there any alternate way to achieve this

Note:- no replacement of the path of img src attribute i.e:- it should be path, but not url/base64 or any

here is the image of my code output, can any one solve this according to the above note conditions




Aucun commentaire:

Enregistrer un commentaire