How to make javascript created image a link
By : Silvio Felipe
Date : March 29 2020, 07:55 AM
|
Is it possible to add the 'sizes' property to a <link> element created by javascript?
By : user3449533
Date : March 29 2020, 07:55 AM
hope this fix your issue I am working on building a plugin for an existing content framework, and need to add elements to the header for mobile favicon support. The only access I am given to do so with the plugin architecture is utilizing javascript. I have successfully written the plugin which generates the elements, but the 'sizes' property is not being included in the generated code, likely as it is an HTML5 property. Is there a cross-browser way to do this? , You can use the setAttribute method: code :
link.setAttribute("sizes","57x57")
|
Set source of image of dynamically created element in JavaScript
By : Ellyn Siegel
Date : March 29 2020, 07:55 AM
will be helpful for those in need HTML elements don't have a getElementById() method, that method is part of the document instance of the HTMLDocument class but your var doc refers to the newly created , not the document. You could have used: code :
let image = document.getElementById('imageId');
let image = doc.querySelector('#imageId');
|
Link in a javascript created image
By : Thor Stenberg
Date : March 29 2020, 07:55 AM
this will help Don't use document.write(). Create a new a element like you created the image and append the image to the anchor element and the anchor element to the wrapper. code :
//define elements
var divWrapper = document.getElementById('wrapper');
var image = document.createElement('img');
var a = document.createElement('a');
//set image attributes
image.src = 'image.png';
image.height = 100;
image.width = 50;
image.style.position = "absolute";
image.style.left = 60 + "px";
image.style.top = 32 + "px";
//set anchor attributes
a.href = "index.php";
//Append the elements
a.appendChild(image);
divWrapper.appendChild(a);
<div id="wrapper"></div>
|
Javascript setting html created element link
By : user119917
Date : March 29 2020, 07:55 AM
|