JavaScript - to get image

Asked By pradeep reddy
10-Feb-12 12:46 AM
Hi 

This is pradeep 
When mouse over the hyper link it has to display the image how to do this can u please send me the code 
its urgent 

Regards
Pradeep
  Somesh Yadav replied to pradeep reddy
10-Feb-12 01:01 AM

Hi pradeep,
you can do this using javascript..

This will create a square that follows your mouse on div or element hover.

Create a .js file with those contents here:

 

var WindowVisible = null;
function WindowShow() {
   
this.bind = function(obj,url,height,width) {
        obj
.url = url;
        obj
.mheight = height;
        obj
.mwidth = width;
        obj
.onmouseover = function(e) {
               
if (WindowVisible == null) {
                       
if (!e) e = window.event;
                       
var tmp = document.createElement("div");
                        tmp
.style.position = 'absolute';
                        tmp
.style.top = parseInt(e.clientY + 15) + 'px';
                        tmp
.style.left = parseInt(e.clientX + 15) + 'px';
                               
var iframe = document.createElement('iframe');
                                iframe
.src = this.url;
                                iframe
.style.border = '0px';
                                iframe
.style.height = parseInt(this.mheight)+'px';
                                iframe
.style.width = parseInt(this.mwidth)+'px';
                                iframe
.style.position = 'absolute';
                                iframe
.style.top = '0px';
                                iframe
.style.left = '0px';
                        tmp
.appendChild(iframe);
                        tmp
.style.display = 'none';
                       
WindowVisible = tmp;
                        document
.body.appendChild(tmp);
                        tmp
.style.height = parseInt(this.mheight) + 'px';
                        tmp
.style.width = parseInt(this.mwidth) + 'px';
                        tmp
.style.display = 'block';
               
}
       
}
        obj
.onmouseout = function() {
               
if (WindowVisible != null) {
                        document
.body.removeChild(WindowVisible);
                       
WindowVisible = null;
               
}
       
}
        obj
.onmousemove = function(e) {
               
if (!e) e = window.event;
               
WindowVisible.style.top = parseInt(e.clientY + 15) + 'px';
               
WindowVisible.style.left = parseInt(e.clientX + 15) + 'px';
       
}
   
}
}


Then in your html do the following:

  1. Include the .js file <script type="text/javascript" src="myfile.js"></script>

  2. Put in your web page:

 

<script type="text/javascript">
               
var asd = new WindowShow();
                asd
.bind(document.getElementById('go1'),'IMAGE URL HERE!',400,480);
</script>

Here is a full implementation in a HTML:

<html>
<head>
       
<title>test page</title>
       
<style>
                div
.block { width: 300px; height: 300px; background-color: red; }
                iframe
{ border: 0px; padding: 0px; margin: 0px; }
       
</style>
       
<script type="text/javascript" src="window_show.js"></script>
</head>
<body>
       
<div id="go1" style="background-color: red; width: 200px; height: 200px;"></div>

       
<script type="text/javascript">
               
var asd = new WindowShow();
                asd
.bind(document.getElementById('go1'),'IMAGE URL HERE!',400,480);
       
</script>
</body>
  Danasegarane Arunachalam replied to pradeep reddy
10-Feb-12 01:06 AM
Use the below method

<html>
<head>
<title>Image Hover</title>
<script type="text/javascript">
function ShowImage(IDS) {
  document.getElementById(IDS).style.display = "block";
}
function HideImage(IDS) {
  document.getElementById(IDS).style.display = "none";
}
</script>
</head>
<body>
<a href="javascript:alert('Link to somewhere.')"
onMouseOver=ShowImage('Img1') onMouseOut="HideImage('Img1')">image</a>
<span id="Img1" style="display:none">
<img src="http://www.techreceipe.com/wp-content/uploads/2011/10/Windows-8.jpg" alt="Windows8" /></span>
</body>
</html>
  Danasegarane Arunachalam replied to pradeep reddy
10-Feb-12 01:10 AM
See the demo here

http://www.techreceipe.com/wp-content/uploads/demo/ImageHyperlink.htm
  dipa ahuja replied to pradeep reddy
10-Feb-12 06:07 AM
You can do it quickly with ajaxhoverMenyExtender:
 
<asp:Image ID="imgpopup" runat="server" ImageUrl="~/1.bmp" />
<asp:Image ID="imghover" Height="20" Width="20" runat="server" ImageUrl="~/1.bmp" />
 
<cc1:HoverMenuExtender ID="hm1" runat="server"
TargetControlID="imghover"
PopupControlID="imgpopup"
PopupPosition="Right" />
 

Using javascript

   <script type="text/javascript">

      function showBig() {

        window.open(document.getElementById('myimage').src, "mywindow");

      }

</script>

<img id=myimage src ="1.bmp" width="80" Height = "100" onmouseover="showBig();"/>

 

  erik little replied to pradeep reddy
03-Apr-12 08:11 PM
       //<img id="linkImg" />
        //<a class="pop" href="Images/SomeImage.jpg">Data</a>
        $('.pop').live('hover', function (e) {
            //e.preventDefault();
            $('#linkImg').css(
            {
                position: 'absolute',
                left: e.target.clientLeft + 15,
                top: e.target.clientTop + 25
            }
            );
            $('#linkImg').attr('src',this.href).mouseleave(function (e) { $(this).clientLeft = -2000; });;
        })
Create New Account
help
thumbnail for images. . . How to generate thumbnail for images. . . hi, / / Declare a class level variable Image imgThumb = null ; private void btnGenerateThumbnail_Click( object sender, EventArgs e) { try { Image image = null ; / / Check if textbox has a value if (txtFileNm.Text ! = String.Empty) image = Image.FromFile(txtFileNm.Text); / / Check if image exists if (image ! = null ) { imgThumb = image.GetThumbnailImage(100, 100, null , new IntPtr()); this .Refresh(); } } catch
retrive images from data base and display the image in a imagecontrol end of post hi, 1. private Image RetrieveImage(int photoId) 2. { 3. System.Drawing.Image image = null; 4. 5. using (SqlConnection connection = new SqlConnection(". . .")) 6. { 7. using (SqlCommand command = connection.CreateCommand()) 8 Open(); 13. byte[] imageData = (byte[])command.ExecuteScalar(); 14. 15. MemoryStream memStream = new MemoryStream(imageData); 16. image = System.Drawing.Image.FromStream(memStream); 17. } 18. } 19. 20. return image; 21. } hope this will help you Here are couple of ways doing this reading bytes
sT, sId, oN) iM = 1 sT = 'IPF.Appointment' sId = 'LgAAAAA6S9e5wVZ2Qbjg3WZmMPJ6AQBaBD+XbSNBSY2dF8i / xwo1AAAA6ahNAAAC' oN = [object] onbeforeunload = null onafterprint = null top = [object] location = https: / / webmail.domain.net / owa / parent = [object] offscreenBuffering = auto frameElement = null onerror = function window.onerror(sMsg, sUrl, sLn){try{sMsg = sMsg.trim();if(isAccDnd(sMsg)){shwErrDlg(0, L_ErrRfBrws oProp.toString()+" = "+event[oProp];}oES.sBdy+ = sEv;}var oDlg = shwErrDlg(0, L_ScptErr, 0, (a_fSndClntErr?L_ScptErrDtls:null), oES.sBdy, a_fSndClntErr);oDlg.oES = oES;}catch(e){window.status = e.message;}return true;} screen = [object] event = [object] clipboardData = [object] onresize = null defaultStatus = onblur = null window = [object] onload = function window.onload(){chkScrpts();} onscroll = null screenTop = 93 onfocus = null Option = [object] length = 1 onbeforeprint = null
How to display image in picturebox I have stored an image displayed in picture box to an access datbase field(OLE filed)as bytes But when I try to retrieve the image to the picturebox an error is seen .how can I solve the problem .plz help Hi, Save the image to the folder. store the image path in the database. Read the image path from the database. Pick the image from the path and display it in the picture box Hi, here is the code for this. . . byte[] imageData = (byte[])dr["iamge field"]; MemoryStream MStream = new MemoryStream(imageData); Image image = Image.FromStream(MStream); pictureBox1.Image = image; MStream.Close(); Step1: OpenFromSqlDatabase method will return object
display image in image control through image path hello, i have store image path in my image table. . which contain ID(int), Image_Path varchar(50). . i want to display image in image control through this image path. . please help me. . Hi, Try something like this < asp:Image ID = "imgPhoto" runat = "server