Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Help With Setting up script please

  1. #1
    Join Date
    Apr 2007
    Location
    Nebraska
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help With Setting up script please

    1) Script Title: Image w/ description tooltip

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...agetooltip.htm

    3) Describe problem: I'm not sure how to set it up because when i mouseover my links i get either Page cannot be displayed or someone elses images pop up. My website is hosted by bravenet and the images I want to use are located in my photobucket album. I need a complete walk through as im a newbie when it comes to scripts. heres the page that the script code is on http://babygirlzcreationz.com/Scrptests.html Thanks for any/all help
    Last edited by Babygirl31; 05-01-2007 at 01:58 AM. Reason: Forgot to add page url

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    This is how your page source should be:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
     <head>
    <script type="text/javascript">
    
    /***********************************************
    * Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
    * Copyright 2002-2007 by Sharon Paine
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    /* IMPORTANT: Put script after tooltip div or 
    	 put tooltip div just before </BODY>. */
    
    var dom = (document.getElementById) ? true : false;
    var ns5 = (!document.all && dom || window.opera) ? true: false;
    var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
    var ie4 = (document.all && !dom) ? true : false;
    var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;
    
    var origWidth, origHeight;
    
    // avoid error of passing event object in older browsers
    if (nodyn) { event = "nope" }
    
    ///////////////////////  CUSTOMIZE HERE   ////////////////////
    // settings for tooltip 
    // Do you want tip to move when mouse moves over link?
    var tipFollowMouse= true;	
    // Be sure to set tipWidth wide enough for widest image
    var tipWidth= 160;
    var offX= 20;	// how far from mouse to show tip
    var offY= 12; 
    var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
    var tipFontSize= "8pt";
    // set default text color and background color for tooltip here
    // individual tooltips can have their own (set in messages arrays)
    // but don't have to
    var tipFontColor= "#000000";
    var tipBgColor= "#DDECFF"; 
    var tipBorderColor= "#000080";
    var tipBorderWidth= 3;
    var tipBorderStyle= "ridge";
    var tipPadding= 4;
    
    // tooltip content goes here (image, description, optional bgColor, optional textcolor)
    var messages = new Array();
    // multi-dimensional arrays containing: 
    // image and text for tooltip
    // optional: bgColor and color to be sent to tooltip 
    
    messages[0] = new Array('/Finished&#37;20Tags/Kisses%20N%20Kuffs%201.jpg','Kisses N Kuffs',"#FFFFFF");  
    messages[1] = new Array('/Finished%20Tags/Electrified%20Seduction%201.gif' 'Electrified Seduction',"#FFFFFF");  
    messages[2] = new Array('/Finished%20Tags/BabygirlThis1.jpg','Babygirl This!', "#FFFFFF");
    ////////////////////  END OF CUSTOMIZATION AREA  ///////////////////
    
    // preload images that are to appear in tooltip
    // from arrays above
    if (document.images) {
    	var theImgs = new Array();
    	for (var i=0; i<messages.length; i++) {
      	theImgs[i] = new Image();
    		theImgs[i].src = messages[i][0];
      }
    }
    
    // to layout image and text, 2-row table, image centered in top cell
    // these go in var tip in doTooltip function
    // startStr goes before image, midStr goes between image and text
    var startStr = '<table width="' + tipWidth + '"><tr><td align="center" width="100%"><img src="';
    var midStr = '" border="0"></td></tr><tr><td valign="top">';
    var endStr = '</td></tr></table>';
    
    ////////////////////////////////////////////////////////////
    //  initTip	- initialization for tooltip.
    //		Global variables for tooltip. 
    //		Set styles
    //		Set up mousemove capture if tipFollowMouse set true.
    ////////////////////////////////////////////////////////////
    var tooltip, tipcss;
    function initTip() {
    	if (nodyn) return;
    	tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
    	tipcss = tooltip.style;
    	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
    		tipcss.width = tipWidth+"px";
    		tipcss.fontFamily = tipFontFamily;
    		tipcss.fontSize = tipFontSize;
    		tipcss.color = tipFontColor;
    		tipcss.backgroundColor = tipBgColor;
    		tipcss.borderColor = tipBorderColor;
    		tipcss.borderWidth = tipBorderWidth+"px";
    		tipcss.padding = tipPadding+"px";
    		tipcss.borderStyle = tipBorderStyle;
    	}
    	if (tooltip&&tipFollowMouse) {
    		document.onmousemove = trackMouse;
    	}
    }
    
    window.onload = initTip;
    
    /////////////////////////////////////////////////
    //  doTooltip function
    //			Assembles content for tooltip and writes 
    //			it to tipDiv
    /////////////////////////////////////////////////
    var t1,t2;	// for setTimeouts
    var tipOn = false;	// check if over tooltip link
    function doTooltip(evt,num) {
    	if (!tooltip) return;
    	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
    	tipOn = true;
    	// set colors if included in messages array
    	if (messages[num][2])	var curBgColor = messages[num][2];
    	else curBgColor = tipBgColor;
    	if (messages[num][3])	var curFontColor = messages[num][3];
    	else curFontColor = tipFontColor;
    	if (ie4||ie5||ns5) {
    		var tip = startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
    		tipcss.backgroundColor = curBgColor;
    	 	tooltip.innerHTML = tip;
    	}
    	if (!tipFollowMouse) positionTip(evt);
    	else t1=setTimeout("tipcss.visibility='visible'",100);
    }
    
    var mouseX, mouseY;
    function trackMouse(evt) {
    	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
    	mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
    	mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
    	if (tipOn) positionTip(evt);
    }
    
    /////////////////////////////////////////////////////////////
    //  positionTip function
    //		If tipFollowMouse set false, so trackMouse function
    //		not being used, get position of mouseover event.
    //		Calculations use mouseover event position, 
    //		offset amounts and tooltip width to position
    //		tooltip within window.
    /////////////////////////////////////////////////////////////
    function positionTip(evt) {
    	if (!tipFollowMouse) {
    		mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
    		mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
    	}
    	// tooltip width and height
    	var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
    	var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
    	// document area in view (subtract scrollbar width for ns)
    	var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
    	var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
    	// check mouse position against tip and window dimensions
    	// and position the tooltip 
    	if ((mouseX+offX+tpWd)>winWd) 
    		tipcss.left = mouseX-(tpWd+offX)+"px";
    	else tipcss.left = mouseX+offX+"px";
    	if ((mouseY+offY+tpHt)>winHt) 
    		tipcss.top = winHt-(tpHt+offY)+"px";
    	else tipcss.top = mouseY+offY+"px";
    	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
    }
    
    function hideTip() {
    	if (!tooltip) return;
    	t2=setTimeout("tipcss.visibility='hidden'",100);
    	tipOn = false;
    }
    
    document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>')
    
    </script>
    
                    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            		<meta name="keywords" content="" />
    		<meta name="description" content="" />
    		<meta name="author" content="" />
    		<title> Babygirlz Creationz  		</title>
    
    		<link rel="stylesheet" type="text/css" href="style.css" />		
    	</head>
    	<body>
    	
    
    	<div id="pageWrapper">
    	
    		<div id="pageHeader">
    			<h1><P align=center><FONT size=3><STRONG>Babygirlz Creationz...Creativity is endless.</P>  <P align=center><STRONG><FONT size=3>Paintshop Pro Tutorials By Yolanda</FONT></STRONG></P></STRONG></FONT>  <P align=center><STRONG><FONT size=3></FONT></STRONG>&nbsp;</P></h1>
    		</div>
    
    		<div id="subPageWrapper">
    		
    		<div id="siteNavigation">
    			<h1>Navigation</h1>
    			<ul>
    								<li><a href="index.html" >Welcome</a></li>
    								<li><a href="Terms.html" >Terms Of Use</a></li>
    								<li><a href="Tutorials.html" >The Tutorials</a></li>
    
    								<li><a href="AboutMe.html" >About Me</a></li>
    								<li><a href="WhatsNew.html" >What's New?</a></li>
    								<li><a href="Links.html" >Links</a></li>
    								<li><a href="Scrptests.html" class="active">Script Tests</a></li>
    							</ul>
    			<div id="listBreaker"> </div>
    
    		</div>
    		
    		
    
    		<div id="extraContent">
    			<div class="contentContainer">
    							</div>
    		</div>
    
    
    	
    
    		<div id="userLinks">
    		
    						<div class="linkSection">
    				<h1>Things To Do</h1>
    
    				<ul>
    									<li><a href="http://pub41.bravenet.com/guestbook/3488957990">Sign my Guestbook</a></li>
    									<li><a href="http://Babygirl30.bravejournal.com">View my Journal</a></li>
    								</ul>
    				</div>
    					</div>	
    
    
    
    		<div id="extraContent2">
    			<div class="contentContainer">
    
    							</div>
    		</div>
    
    		
    
    		<div id="mainContent">
    			<div class="contentContainer">
    			<BR style="DISPLAY: none">  
    
    <A onmouseover="doTooltip(event,0)" onmouseout="hideTip(event,0)" href="http://pub41.bravenet.com/hosting/cms/0">Preview</A><BR>
    
    <A onmouseover="doTooltip(event,1)" onmouseout="hideTip(event,1)" href="http://pub41.bravenet.com/hosting/cms/2">Preview</A><BR>
    
    <A onmouseover="doTooltip(event,2)" onmouseout="hideTip(event,2)" href="http://pub41.bravenet.com/hosting/cms/2">Preview</A><BR>		
    	</div>
    		</div>
    	
    		<div id="subPageBreaker"></div>
    		</div>
    		
    		<div id="pageFooter">
    			<h6><P align=center>All Content provided by Yolanda/Babygirlz Creationz&nbsp;2007-2008</P>  <P align=center>Artwork &#169;Keith Garvey www.garvgraphx.com</P></h6>
    		</div>
    	</div>
     </body>
    </html>
    Now for a break-down. The part in red (as said in the instructions on the demo page) goes in between the <head> tags. Then, notice the quotes (in blue) in the links around the function to do onmouseover/mouseout. There's not much more then that. If you need any more help, let us know.
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Apr 2007
    Location
    Nebraska
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks just one more question. do i add the image url where the image is supposed to go?

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    How do you mean, do you mean where the link redirects to, or in the image popup?
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Apr 2007
    Location
    Nebraska
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i added the image url like this: messages[0] = new Array('/Finished&#37;20Tags/Kisses%20N%20Kuffs%201.jpg' is that the correct way? Also, for some reason when I mouseover the link, the image doesn't automatically pop up. I have to click the link to see it. Am I still doing something wrong or is it that my webhost (bravenet) doesn't support Java Script?
    Last edited by Babygirl31; 05-01-2007 at 06:19 PM. Reason: had another question

  6. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Try removing the new Array();
    Code:
    messages[0] = '/Finished&#37;20Tags/Kisses%20N%20Kuffs%201.jpg'
    - Mike

  7. #7
    Join Date
    Apr 2007
    Location
    Nebraska
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    will do. thanks

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    thetestingsite,

    The meta tags and title should come before the style and then be followed by the script.

    Quote Originally Posted by mburt View Post
    Try removing the new Array();
    Code:
    messages[0] = '/Finished%20Tags/Kisses%20N%20Kuffs%201.jpg'
    That's not how this script is supposed to be used.


    Babygirl31,

    There may be other problems but, on your page linked to in your first post in this thread, you have somehow managed to strip out all of the line breaks in the script so that it has become one huge long uninterrupted line. The line breaks in the code are there for a reason. Most of them cannot be skipped without rewriting the code.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Apr 2007
    Location
    Nebraska
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mburt View Post
    Try removing the new Array();
    Code:
    messages[0] = '/Finished%20Tags/Kisses%20N%20Kuffs%201.jpg'
    I tried your suggestion and am still having to click to see the image I use IE7 if that matters. Thanks.

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The browser may matter, but certainly not which one YOU use..... anyone who views your site should be able to see it, so it should work on all of them... yes, including IE7, but not limited to it.

    As for the question, I'm sure they'll respond soon. I'm not quite sure what's going on with the script, so not sure what to say.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •