6 Years
Discussion Span
Last Post by almostbob

If you want to get as tool tip

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


<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...

Edited by ypks_destiny: n/a


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,/, "");

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

<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

Edited by almostbob: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.