Solved

webpart mouseover/ tooltip

Posted on 2010-11-11
8
1,822 Views
Last Modified: 2012-05-10
Hi,

I have a dataviewer webpart which shows data from splist. One of the columns in the dataviewer webpart has an image in it and when you put your mouse tip on it, it should open a div as a pop up and show the list items in an html table.
I could use flash or silverlight to make ithe mouse tool tip/mouse over pop up look fancier.

Could you please provide any step-by-step procedure to do it?

Thanks,
Rohit.
0
Comment
Question by:RohitRepu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 43

Expert Comment

by:zephyr_hex (Megan)
ID: 34122015
0
 

Author Comment

by:RohitRepu
ID: 34122210
Hi Zephyr,
sort of yes, except that i have text to display not images when hovered over.

thanks.
0
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 400 total points
ID: 34133930
Hi, RohitRepu. You could use this to get this effect. First create a div for html table:

CSS
#htmlTable{
  //put your style attributes here
}

In html file write this:

HTML
<div id="htmlTable" style="display:none;">
  put here your code
</div>

This div will be invisible. To your links which has to have hover effect give a class name such 'class='mylink' in order to allow a reference for jQuery.

Now we have to customize javascript code (see snippet below).

I've not tested I use prototype and scriptaculous)ù not jQuery) but I think it could work.

Let me know.
Cheers
function tablePreview(){
	    $("mylink").hover(function(e){
	        var obj = $("htmlTable");
	        var offset = $(this).offset();
	        var winHeight = $(window).height();
	        var winWidth = $(window).width();
	        var scrollLeft = $(window).scrollLeft();
	        var scrollTop = $(window).scrollTop();
	        var objHeight = obj.outerHeight();
	        var objWidth = obj.width()+15;
	        if(((winWidth+scrollLeft)-offset.left)<objWidth){
	            offset.left=((winWidth+scrollLeft)-objWidth);
	        }
	        var maxHeight = (winHeight+scrollTop)-offset.top;
	        if(objHeight>maxHeight){
	            if(offset.top-scrollTop>objHeight){
	                offset.top=offset.top-objHeight-20;
	            }
	            height = (objHeight<winHeight)?objHeight:winHeight;
	        }
	        obj.css({"position":"absolute","top":(offset.top+20)+"px","left":offset.left+20})
	        .fadeIn("fast");
	    },
	    function(){
	        $("htmlTable").remove();
	    });
	};

	// Call the script on page load
	$(document).ready(function(){
	    imagePreview();
	});

Open in new window

0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 31

Assisted Solution

by:Marco Gasi
Marco Gasi earned 400 total points
ID: 34134168
I'm sorry, I forgot to specify that I have used code shown in link posted by zephyr_hex. So you have to use jQuery. I post complete code to insert in the head of your page for javascript.

Cheers
<script type="text/javascript" src="../../Javascript/jquery-1.4.2.min.js"></script>
<script type="text/javascript">

function tablePreview(){
	    $("mylink").hover(function(e){
	        var obj = $("htmlTable");
	        var offset = $(this).offset();
	        var winHeight = $(window).height();
	        var winWidth = $(window).width();
	        var scrollLeft = $(window).scrollLeft();
	        var scrollTop = $(window).scrollTop();
	        var objHeight = obj.outerHeight();
	        var objWidth = obj.width()+15;
	        if(((winWidth+scrollLeft)-offset.left)<objWidth){
	            offset.left=((winWidth+scrollLeft)-objWidth);
	        }
	        var maxHeight = (winHeight+scrollTop)-offset.top;
	        if(objHeight>maxHeight){
	            if(offset.top-scrollTop>objHeight){
	                offset.top=offset.top-objHeight-20;
	            }
	            height = (objHeight<winHeight)?objHeight:winHeight;
	        }
	        obj.css({"position":"absolute","top":(offset.top+20)+"px","left":offset.left+20})
	        .fadeIn("fast");
	    },
	    function(){
	        $("htmlTable").remove();
	    });
	};

	// Call the script on page load
	$(document).ready(function(){
	    imagePreview();
	});
</script>

Open in new window

0
 
LVL 28

Assisted Solution

by:sybe
sybe earned 100 total points
ID: 34134308
pure css is the nicest solution: http://psacake.com/web/jl.asp

If you insist on javascript, don't use jquery, it only complicates things.
0
 

Author Closing Comment

by:RohitRepu
ID: 34242770
thanks
0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question