Add VML elements (images) using javascript

Hi, I am trying to add VML image elements using javascript. now here is what i use to create these images:

function add_tools()
{       
var elemm = document.createElement('rvml:image'); 
elemm.setAttribute('src', 'pic.png');
elemm.setAttribute('id', 'gogo');
elemm.setAttribute('class', 'rvml');
document.body.appendChild(elemm);   

document.getElementById('gogo').style.position='absolute';
document.getElementById('gogo').style.width=55;
document.getElementById('gogo').style.height=55;
document.getElementById('gogo').style.top=200;
document.getElementById('gogo').style.left=300;
document.getElementById('gogo').style.rotation=200;
document.getElementById('gogo').style.display = "block"; 
}

Usually, when I generate a vml image element, the HTML code should look something like this:

<rvml:image style="POSITION:absolute; WIDTH:55px; HEIGHT:55px; TOP:0px; LEFT:0px; rotation:0;" src="pic.png" id=gogo class=rvml>

now the aforementioned javascript function works with HTML elements. but when I use it to create VML elements. the generated item is not displayed in the browser. but when I check document.body.innerHTML. I see that the item is actually created. but not shown.

any ideas? is there any method that i can use to update or redraw elements using javascript. or anything that I can fix.

thank

+3
2

. ...

function add_tools()
{   
var elemm = document.createElement('rvml:image'); 
elemm.src = 'pic.png';
elemm.className = 'rvml';
document.body.appendChild(elemm);
elemm.id = "gogo";
elemm.style.position='absolute';
elemm.style.width=55;
elemm.style.height=55;
elemm.style.top=200;
elemm.style.left=300;
elemm.style.rotation=200; 
}

, setAttribute . . , :

elemm.onload = "alert('coco')";

, javascript, . , . , kindda . innerHTML, .

0

, :

<div style="position:relative">
  <vml:rect stroked="f" style="position:absolute"> 
    <vml:fill type="tile" aspect="ignore" src="pathto.png" style="position:absolute">  
    </vml:fill>
  <vml:rect> 
</div>

, , , div.

superpng jQuery, png alpha.

+2

Source: https://habr.com/ru/post/1755676/


All Articles