Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to change the position of popup dynamically like when i show popup onmouse hover of hyperlink, popup always shows at bottom of the hyperlink, in this case when hyperlink is at end of the browser then more than half of the goes hide.

So, I need the popup position change according to the space, if the hyperlink is at end then popup show at top of the hyperlink otherwise at bottom.

How could i achieve this task ?
Posted

1 solution

this is what you might be looking for

HTML
<body style="height:1000px;">
        <div style="margin-top:800px;"></div>
        <a href="" class="link" onmouseover="showTitle()">your link show title</a><body></body></body>


JavaScript
<script>
function showTitle(){
	var link = document.getElementById("link");
	
	if(screen.height	 	link.style.top="-200%";
	}else{
		link.style.top="100%";		
	}
}
</script>


CSS
<style>
.link{
position:relative;		
}
.anchorTitle{
display:none;
position:absolute;
background:#F60;	
}
.link:hover .anchorTitle{
display:block;	
background:#F60;
}
</style>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900