Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem calling an ASP function

Status
Not open for further replies.

Cineno

Programmer
Jul 24, 2006
142
US
I have a small pop-up window that I want to only pop-up when the user moves his mouse over a certain block of text. Currently this block of text is also a link.

I am using a the script I found here:
I tried putting the html that makes the pop-up window (the part in Step 2 in the link above) in an ASP function, and call it in the text's onmouseover property. Ex: <a href="demoPage.asp" onmouseover="Description()">

So far it's not working and when the page loads, the pop-up window is already open and I can't click it or anything.

Anyone have any ideas how I can do this? Or at least use the script found on that page in a way that it is called only when someone mouseover's some text? Any help is appreciated.
 
it seems to me you would be better off using tooltips vs a popup window...you can take advantage of not having to use javascript by using the title attribute in the link. (popups could be blocked on browser and is very annoying)

if the description is too detailed then you may have to go with javascript to help...lookup javascript tooltips in google and i think you'll find what you'll need...here's one that generates the code for you

 
Anytime you want the browser to execute a function, code, etc yu need to keep it to the client-side. ASP runs only on the server and only runs long enough to generate content to tsend to the browser. At that point it is done and is cleaned up. In the meantime the data it produced (be it an HTML file, image, whatever) has just finished streaming to the client-side browser and is probably just starting the onLoad events.

Basically you need to copy that first chunk of code into your page and output it somewhere in the <head> section. The second chunk (a poor example piece in my mind) is the actual HTML for the box that you would output somewheer in your body tag, with some content where it has the comments.

A better example of this (breaking NS4 compliance, welcome to the new millenium) would be:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
	<script type="text/javascript">

	/******************************************
	* Popup Box- By Jim Silver @ jimsilver47@yahoo.com
	* Visit [URL unfurl="true"]http://www.dynamicdrive.com/[/URL] for full source code
	* This notice must stay intact for use
	******************************************/

	var ns4=document.layers
	var ie4=document.all
	var ns6=document.getElementById&&!document.all

	//drag drop function for NS 4////
	/////////////////////////////////

	var dragswitch=0
	var nsx
	var nsy
	var nstemp

	function drag_dropns(name){
	if (!ns4)
	return
	temp=eval(name)
	temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
	temp.onmousedown=gons
	temp.onmousemove=dragns
	temp.onmouseup=stopns
	}

	function gons(e){
	temp.captureEvents(Event.MOUSEMOVE)
	nsx=e.x
	nsy=e.y
	}
	function dragns(e){
	if (dragswitch==1){
	temp.moveBy(e.x-nsx,e.y-nsy)
	return false
	}
	}

	function stopns(){
	temp.releaseEvents(Event.MOUSEMOVE)
	}

	//drag drop function for ie4+ and NS6////
	/////////////////////////////////


	function drag_drop(e){
	if (ie4&&dragapproved){
	crossobj.style.left=tempx+event.clientX-offsetx
	crossobj.style.top=tempy+event.clientY-offsety
	return false
	}
	else if (ns6&&dragapproved){
	crossobj.style.left=tempx+e.clientX-offsetx+"px"
	crossobj.style.top=tempy+e.clientY-offsety+"px"
	return false
	}
	}

	function initializedrag(e){
	crossobj=ns6? document.getElementById("showimage") : document.all.showimage
	var firedobj=ns6? e.target : event.srcElement
	var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
	while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
	firedobj=ns6? firedobj.parentNode : firedobj.parentElement
	}

	if (firedobj.id=="dragbar"){
	offsetx=ie4? event.clientX : e.clientX
	offsety=ie4? event.clientY : e.clientY

	tempx=parseInt(crossobj.style.left)
	tempy=parseInt(crossobj.style.top)

	dragapproved=true
	document.onmousemove=drag_drop
	}
	}
	document.onmouseup=new Function("dragapproved=false")

	////drag drop functions end here//////

	function hidebox(){
	crossobj=ns6? document.getElementById("showimage") : document.all.showimage
	if (ie4||ns6)
	crossobj.style.visibility="hidden"
	else if (ns4)
	document.showimage.visibility="hide"
	}

	</script>
	<style>
	#showimage{
		border: 2px solid #000080;
		position:absolute;
		width:250px;
	}
	#dragbar{
		background-color: #000080;
		font-family: verdana;
		font-weight: bold;
		font-size: 8pt;
		color: #FFFFFF;
		cursor: pointer;
	}
	#closeLink{
		display: block;
		float: right;
	}
	#closeLink img{
		width: 16px;
		height: 14px;
	}
	#content{
		background-color: white;
		padding: 4px;
	}
	</style>
</head>
<body>

	<div id="showimage" style="left:250px;top:250px">
		<div id="dragbar" onMousedown="initializedrag(event)" onMouseover="dragswitch=1;if (ns4) drag_dropns(showimage)" onMouseout="dragswitch=0">
			<a href="#" id="closeLink" onClick="hidebox();return false"><img src="close.gif" border=0></a>
			Announcement Box
		</div>
		<div id="content">
		<!-- PUT YOUR CONTENT BETWEEN HERE -->

		Testing 1 2 3

		<!-- END YOUR CONTENT HERE -->
		</div>
	</div>

</body>
</html>

The javascript could be reduced also, but I have to be getting to work and client-side Javascript has it's own forum.

-T

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top