Solved

Line breaks in javascript mouseover text

Posted on 2009-05-20
11
480 Views
Last Modified: 2013-11-19
Is it possible to have a line break in the javascript text for a mouseover?  The following is the code for the mouseover

<img src="images/alliancelogos/dtzlogo.gif" width="173" height="70" alt="Premier Communities" onMouseover="ddrivetip('DTZ Rockwood - Throughout its 18-year history, DTZ Rockwood has specialized in advising clients regarding the resolution of underperforming assets. Website: www.dtzrockwood.com. Contact: Steven Jacobs Phone: 212-286-5800','white', 300)";
onMouseout="hideddrivetip()"/>

the following is the javascript code that I used.  Any help would be appreciated!

<div id="dhtmltooltip"></div>

<script type="text/javascript">

/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

</script>
0
Comment
Question by:kmurphychi
  • 4
  • 3
  • 2
11 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 24435555
Well it should be perfectly possible to use html in the popup, so you could use <br/> but haven't studied that script. Try putting in <br/> for the hell of it
0
 

Author Comment

by:kmurphychi
ID: 24435758
I've tried putting the html break in there, but every time I do that it breaks the code and the mouseover doesn't work anymore.
0
 
LVL 92

Expert Comment

by:objects
ID: 24437110
use \n for line breaks

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24437187
>>it breaks the code

Try escaping the tags
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:kmurphychi
ID: 24437668
I used <br> and that worked.  the \n didn't work and the escape tags didn't work either.  Thank you for the help though!
0
 
LVL 92

Expert Comment

by:objects
ID: 24437697
next time ask the question in javascript zone instead of Java
far better chance of getting an answer :)

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24438179
>>I used <br> and that worked.

(which was the first thing i mentioned using) - http:#24435555
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24505132
:-)
0
 

Author Comment

by:kmurphychi
ID: 24505149
In case anyone else has this problem, </br> did not work, but <br> did.  The / broke the code.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now