Line breaks in javascript mouseover text

Posted on 2009-05-20
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: Contact: Steven Jacobs Phone: 212-286-5800','white', 300)";

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 (
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at 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")"px"
if (typeof thecolor!="undefined" && thecolor!="")
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 ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)"5px"
//position the horizontal position of the menu where the mouse is positioned"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight) ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"

function hideddrivetip(){
if (ns6||ie){


Question by:kmurphychi
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
  • 4
  • 3
  • 2
LVL 86

Accepted Solution

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

Author Comment

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.
LVL 92

Expert Comment

ID: 24437110
use \n for line breaks

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

LVL 86

Expert Comment

ID: 24437187
>>it breaks the code

Try escaping the tags

Author Comment

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!
LVL 92

Expert Comment

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

LVL 86

Expert Comment

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

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

Expert Comment

ID: 24505132

Author Comment

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

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

691 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