i want to get a data on image by using <img> tag can any one sortr this out

Recommended Answers

All 5 Replies

can you elaborate your question please....

If you want to get as tool tip

<img src="path" alt="click me"/>

or

<img src="path" title="Click me"/>

I am having a registration form in html..i want registration page in a IMAGE..I tried using

<body background="C:\Documents and Settings\Prashanth.yatakeeri\Desktop\Winter.gif" WIDTH="1000" HEIGHT="800">

this but the image is coming in four parts as the image is small..i tried using width and height also but its not working...

You will need to create a canvas element with the correct dimensions and copy the image data with the drawImage function. Then you can use the toDataURL function to get a data: url that has the base-64 encoded image.

It would be something like this. I've never written a Greasemonkey script, so you might need to adjust the code to run in that environment.

function getBase64Image(img) {
    // Create an empty canvas element
    var canvas = document.createElement("canvas");
    canvas.width = img.width;
    canvas.height = img.height;

    // Copy the image contents to the canvas
    var ctx = canvas.getContext("2d");
    ctx.drawImage(img, 0, 0);

    // Get the data-URL formatted image
    // Firefox supports PNG and JPEG. You could check img.src to
    // guess the original format, but be aware the using "image/jpg"
    // will re-encode the image.
    var dataURL = canvas.toDataURL("image/png");

    return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}
<body><img src='C:\Documents%20and%20Settings\Prashanth.yatakeeri\Desktop\Winter.gif' width='100%' style='z-index:-1;' alt=''>

excusing inline style, get it out into css where it belongs

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.