Click to See Complete Forum and Search --> : How do u insert an image instead of text?
Prime
02-07-2008, 08:29 AM
I am very new to this I found a great bookmark script that inserts texts but I have a picture and I want to use that instead how do I do it heres what I do to insert it as text.
<script type="text/javascript" src="../add_bookmark.js">
</script>
<p id="addBookmarkContainer"></p>
magentaplacenta
02-07-2008, 11:32 AM
?
<script type="text/javascript">
function addImage() {
var container = document.getElementById("container");
var img = document.createElement("img");
img.src = "http://www.google.com/logos/lunarnewyear08.gif";
img.style.display = "block";
container.appendChild(img);
}
</script>
<input type="button" onclick="addImage();" value="add google logo"><p>
<div id="container">I'm so lonely without an image</div>
why?
img.style.display='block'
Why block? Images are inline elements by default. Maybe Prime needs an inline type of picture...
Prime
02-07-2008, 12:00 PM
thnks guys I fixed it i had to do it within the javascript file.
magentaplacenta
02-07-2008, 02:48 PM
why?
img.style.display='block'
Why block? Images are inline elements by default. Maybe Prime needs an inline type of picture...
So the image would display underneath the "I'm so lonely without an image" text. If he needs an inline picture he could........change the display value. What's he going to do if he doesn't want the google logo? END OF WORLD. :eek:
usually, if the developer needs a block aspect for an image, he nests it inside a block-level element, such a DIV.
When you give a block aspect to an element, that element gains new properties, such as margins. Some browsers (IE) gives automatically a 1px margin to a block-leveled image element, which could spoil the design...