JavaScript - Image As A Tooltip... Visit This Website...... You Will Come To Know What Is My Probl
<script type='text/javascript'>
$(window).load(function () { $('area').each(function (e) { var area = $(this), alt = area.attr('id'); if (alt != null) { area.mouseenter(function () { var newImage = $('<img />'); newImage.attr('src', 'ReadImage.ashx?id=' + alt); // call handler with id $('.display').append(newImage); }; } e.preventDefault(); }); }); </script> <div class="display"> </div> <img src="3rd_Floor_screen-size.jpg" width="1372" height="906" border="0" alt="" usemap="#Map" /></div> <map name="Map" id="Map"> <area id="1" alt="1" class="tooltip" shape="rect" coords="28, 87, 93, 181" href="#"/> <area id="2" alt="2" class="tooltip" shape="rect" coords="95, 91, 172, 158" href="#"/> <area id="3" alt="3" class="tooltip" shape="rect" coords="175, 90, 225, 157" href="#"/> </map> I am gettting image on mouseover, if i over the mouse on area id =1. That id 1 will be passed to the ashx page through the script. The ashx page returns my image from the database. I am loading that image in the div display. Now what i need is i have to display the image as a tooltip not in a div........ For example: Visit this following website. http://visitmix.com/labs/glimmer/samples/tooltip.html Can anybody suggest me a solution to do this? I know there is an easy way to do this...... i have brought 60 percent. Now what i need is i have to get this image as a tooltip when i move the mouse over the area id =1.. Thanks Similar TutorialsFirst of all, hi everyone I'm new to the forum and relatively new to javascript. I just completed a course in it at university and I did pretty well but I think we all know "real life" coding is a whole other story. Now, down to business. I'm writing up a script, derived from a sitepoint example (available for download here). I want to bring up a dynamic tool tip, on mousover of a thumbnail, that contains one large picture. The style for the tooltip is handled in the css sheet and therefor not featured here. I am also using the sitepoint Core library, similarly available for download at the aforementioned link. I've been working on this for a while with no success. Here's what I know for certain so far: the showTipListener is running on mouseover the span and the img are being created the img is receiving the correct src the img is being attached to the span the span is being attached to the thumbnail What I don't know is why the tooltip never appears and why the default action is not being canceled. Any thoughts would be greatly appreciated, thanks in advance for your help! I've published the page here so that you all can observe it's behavior. An of course here's the code Code: // JavaScript Document var Tooltips = { //contains the source for each full sized image fullImages: [ "PhotoPortfolio/AdriSelfPortraits.jpg", "PhotoPortfolio/AmyUtah.jpg", "PhotoPortfolio/AveQ.jpg", "PhotoPortfolio/Bingham.jpg", "PhotoPortfolio/BinghamD12.jpg", "PhotoPortfolio/Campus.jpg", "PhotoPortfolio/Campus2.jpg", "PhotoPortfolio/Clambake.jpg", "PhotoPortfolio/Construction.jpg", "PhotoPortfolio/DadInKobeJapan.jpg", "PhotoPortfolio/DadInTheGarden.jpg", "PhotoPortfolio/HesperSongWriter.jpg", "PhotoPortfolio/IrishCoast.jpg", "PhotoPortfolio/NathanHale.jpg", "PhotoPortfolio/NorthConway.jpg", "PhotoPortfolio/Oreo.jpg", "PhotoPortfolio/Portsmouth.jpg", "PhotoPortfolio/Portsmouth2.jpg", "PhotoPortfolio/Portsmouth3.jpg", "PhotoPortfolio/RockClimbing.jpg", "PhotoPortfolio/RockClimbing2.jpg", "PhotoPortfolio/RockClimbing3.jpg", "PhotoPortfolio/RockClimbing4.jpg", "PhotoPortfolio/RockClimbing5.jpg", "PhotoPortfolio/RockClimbing6.jpg", "PhotoPortfolio/RockClimbing7.jpg", "PhotoPortfolio/Seaport.jpg", "PhotoPortfolio/Seaport2.jpg", "PhotoPortfolio/Snowbird.jpg", "PhotoPortfolio/VanderbuiltSkies.jpg", "PhotoPortfolio/VanderbuiltSkies2.jpg", ], init: function() { //collects all the images on the page with the RollOverMe class and stroes them in image var image = Core.getElementsByClass("RollOverMe"); //adds the event listener to all images' mouseover and mouseout events for (i=0; i<image.length; i++) { Core.addEventListener(image[i], "mouseover", Tooltips.showTipListener); Core.addEventListener(image[i], "mouseout", Tooltips.hideTipListener); } }, showTip: function(image) { //retrieve the class number and strip out the string characters, store the number to a variable var sourceMatch = /(^| )source(\d+)( |$)/.exec(image.className); var source = parseInt(sourceMatch[2], 10); //creates a span element var tip = document.createElement("span"); //assigns it to the class tooltip tip.className = "tooltip"; //creates an image var tipImage = document.createElement('img'); //sets the src attribute to appropriate element in the fullImages property using the variable source tipImage.src = Tooltips.fullImages[source]; //attaches the image to the span tip.appendChild(tipImage); //attaches the span to the thumbnail image.appendChild(tip); //sets the tooltip property to display the span image._tooltip = tip; // Fix for Safari2/Opera9 repaint issue document.documentElement.style.position = "relative"; }, hideTip: function(image) { if (image._tooltip) { image.removeChild(image._tooltip); image._tooltip = null; // Fix for Safari2/Opera9 repaint issue document.documentElement.style.position = "static"; } }, showTipListener: function(event) { Tooltips.showTip(this); Core.preventDefault(event); }, hideTipListener: function(event) { Tooltips.hideTip(this); } }; Core.start(Tooltips) Hello all; I am doing a site for a local business that uses radio advertising and has a jingle that they want to play once per visit only (so it does not play over again of they return to the same page later that day). I have tried to use yahoo player, Google player and the infamous wma player and all work well. I especially like the yahoo player but as will all the players I could not find a way to have it only play once per day per visitor. Is there a way to accomplish this? I was thinking using a tracking cookie but have no idea how to implement it. In the end I would like to accomplish the following: mp3 plays automatically on page load audio only playes once per day per visitor hava small player so if the visitorr wants to hear the jingle again they can do so. the player should be compact and cross browser compatible. Should be compatible with HTML 5.0 Transitional or at the very least 4.01 Any help would be appreciated. Hello. I'm trying to set up a login formular with PHP and JavaScript/jQuery. Currently it sends an alert box, if some information are wrong. If correct, it refreshes the page, and everyone's happy. However, I noticed upon the first visit, I cannot log in. Lets say I go to www.mysite.com and try to login, it displays a blank alert box, when it's suppose to display the username, that I supplied, and is wrong... however, it's blank. BUT! If I go to another page and login with false informations, an alert box with the wrong username pops up - if I login with correct informations, it works. How come it won't work on first visit? What am I doing wrong here? Pressing F5 won't work either - I have to manually switch to another page for it to work. Any suggestions and ideas are welcome and appreciated. I'll supply the codes necessary for anyone to help me, but at this point I'm completely blank on which of my codes may be the problem. EDIT - IMPORTANT INFORMATION! Now THIS is weird! I just noticed it's because there's not www. in the URL. There has to be www. for it to work, why is this? I forced the client to have www. in the URL with .htaccess, but I'd still like to know, why this problem occurs without it. I have a site using Grey Box pop up ( http://therdkgroup.com/) . It automatically pops up when you go to any of the 5 pages on the site. Is it possible to add a cookie to it so that it only pop up the first time someone comes to any one of the pages? If so, can you point me in the right direction on how to solve this?? Hi all, I'm trying to find what I'm sure is a simple bit of js which I can use that will close a div for the duration of a users visit as it would hide a notice I'd only want to display once on a site. Essentially all I'd want to do is have a simple div with a paragraph and a link to close the div but to have it remember across pages that the user has dismissed the notice. I noticesearched around and found a similar request here but I don't know js enough to replace the inputs in the example to a simple link and to remove the show div functionality. Anyone able to provide me with any pointers on how I'd be able to achieve this? Many thanks, J. I was trying to display time of last visit along with login name.. can someone help me on this pls? Hi there, I was wondering if there were any scripts (or if you could build be one) which allow first-time visitors to read through step by step tooltips which explain features of a system. For example, users could click on "next" to make that tooltip dissapear, and the next tooltip reappear. ANy help would be great, Thanks Hi! First post here! Would really appreciate some help on a javascript that would display the time elapsed since a particular visitor last visited my webpage, using cookies. So basically it should show something like: "You last visited my page 2 days & 12 mins ago!" I've a little background in java but none in javascript... Thanks so much! Can a random page be loaded without a prior visit to a site? I have a list of 15 people with a photo and contact information in a table with 3 columns and 5 rows. The issue is that the people near the bottom want a chance to be at the top the first time the page is viewed. It is unlikely that a second visit would happen. Is this possible to load a random page for a site without it being viewed or logged into before, therefore no cookies will be used. My knowledge of Java script code is limited so any help would be great. Thanks Motty Hi everyone. New to javascript here.... I have a problem here. I know how to store a cookie and check a cookie... but i don't know how to calculate the time between current visit and previous visit... Example. I logged in @ 1pm and logged in again @ 3pm... It should a msg like "your last visit was 2 hours ago" Can any one enlighten me ? Thank you! Hi, i have some users picture in a page that is coming from database with php mysql_fetch_array function. what i want to do it, When mouse moves to any user's picture then then a small box should appear with that user's profile information with ajax and when mouse moves out it should disappear. and the box position should be with the mouse. please give me some sample code Anyone got any idea why this script won't work in IE (crap)? Working example (FF): http://martynleeball.x10hosting.com/tooltip.htm Code: function obj_position(obj,id) { //Setup variables to hold position values var left = top = 0; if (obj.offsetParent) { do { //Get position values and put in variables left += obj.offsetLeft; top += obj.offsetTop; } while (obj = obj.offsetParent); } //Get alt content for tooltip var alt_message = document.getElementById(id).getAttribute('alt'); return left+","+top+","+alt_message; } function display_tooltip(obj) { //Get the elementID first var elmID = obj.id; //First of all get the position data for current element //Also get the message to be displayed- contained in the alt var pos_mess = obj_position(obj,elmID); //Now splitup the returned string to get the lef _position, right //position and the message to be displayed var part = pos_mess.split(","); //Create variables for the parts var left_pos = part[0]; var top_pos = part[1] - 18; var message = part[2]; var container = document.getElementById('tooltip_container'); var newdiv = document.createElement('div'); newdiv.setAttribute('id','tooltip'); newdiv.className = 'tooltip_style'; newdiv.innerHTML = message; //Position div newdiv.style.position="absolute"; newdiv.style.top=top_pos+"px"; newdiv.style.left=left_pos+"px"; //Append newly created div to container container.appendChild(newdiv); } function delete_tooltip() { var container = document.getElementById('tooltip_container'); var old_div = document.getElementById('tooltip'); container.removeChild(old_div); } How can I make it to where an image will load in the corner of a website? Specifically, I have part of a template I want all people to see, however, some people either get it cut off or not shown at all because of their resolution. Hi, I am using a tooltip that uses the following javascript Code: <script type="text/javascript"> $(document).ready(function() { //Tooltips $(".tip_trigger").hover(function(){ tip = $(this).find('.tip'); tip.show(); //Show tooltip }, function() { tip.hide(); //Hide tooltip }).mousemove(function(e) { var mousex = e.pageX - 90; //Get X coodrinates var mousey = e.pageY - 400; //Get Y coordinates var tipWidth = tip.width(); //Find width of tooltip var tipHeight = tip.height(); //Find height of tooltip //Distance of element from the right edge of viewport var tipVisX = $(window).width() - (mousex + tipWidth); //Distance of element from the bottom of viewport var tipVisY = $(window).height() - (mousey + tipHeight); if ( tipVisX < 90 ) { //If tooltip exceeds the X coordinate of viewport mousex = e.pageX - tipWidth - 90; } if ( tipVisY < 90 ) { //If tooltip exceeds the Y coordinate of viewport mousey = e.pageY - tipHeight - 90; } //Absolute position the tooltip according to mouse position tip.css({ top: mousey, left: mousex }); }); }); </script> As you can see I have set its X position at -90 and y position at -400 so that It could be displaying well when the mouse is hover over a link and it do appear well in the testing page http://bloghutsbeta.blogspot.com/201...slidernav.html If you put your mouse over ALEX in 'A' category BUT from the same test site but in different location from above here http://bloghutsbeta.blogspot.com/201...ting-main.html if you put your mouse over ALEX under 'SIMULATION' category then you will see that the tooltip is way down. Not even that the tooltip moves away if the screen resolution changes. I changed value again and again but didn't reach any conclusion, can someone help me with this issue as what to do to fix it? Note: If you require a complete markup please let me know in comment, I considered it not required that's why I didn't added it to my post ^^ I have a the following code for displaying a tooltip: Code: <a style='margin-left: 10px; position:relative' class="tooltip" title="This is some text to display"> The javascript for the tooltip is as follows: Code: $(document).ready(function(){ $("a.tooltip").live( { mouseenter: function(e){ this.t = this.title; this.title = ""; $("body").append("<p id='tooltip'>"+ this.t +"</p>"); $("#tooltip") .css("top",(e.pageY - 10) + "px") .css("left",(e.pageX + 20) + "px") .fadeIn("fast"); var css_width = $('#tooltip').width(); var text_width = $('#tooltip').textWidth(); if (css_width > text_width) { $('#tooltip').width(text_width); } }, mouseleave: function(){ this.title = this.t; $("#tooltip").remove(); } } ); }); $.fn.textWidth = function textWidth() { var html_org = $(this).html(); var html_calc = '<span>' + html_org + '</span>'; $(this).html(html_calc); var width= $(this).find('span:first').width(); $(this).html(html_org); return width; } What I want to do is to be able to add another variable 'width' to be able to set the width of the tooltip like so: Code: <a style='margin-left: 10px; position:relative' class="tooltip" width="100" title="This is some text to display"> This width will then be passed into the javascript above and used to set the width of the tooltip. How can I modify the above code to do this?? Thanks Hi all, I am fairly new to javascript and finaly found a tooltip script that I want to use. (man there is a lot of them out there). I got it to work no problem and the editing is real easy. The problem is that it is a tool tip for a text link. Would like to know if it is possible to use this with an image that is linked to a site. The script and code is at http://www.javascriptkit.com/script/...ltooltip.shtml The part that I think needs editing is Code: <a href="http://www.javascriptkit.com/dhtmltutors/ajaxticker/index.shtml" rel="htmltooltip">RSS Ajax Ticker</a> Either that or the other part in the body section Code: <!--Inline HTML Tooltips (DIV with class="htmltooltip"--> <!--Matched up with anchor links with rel="htmltooltip" and in the order they appear within page's source--> Thanks in advance for any help in this. Scott Is it possible to prevent the tooltip that appears when mousing over an image from appearing? This is without removing the alt or title tags.
hi! i would just like to say first of all, that i only use forums for help unless i've exacerbated all other forms of help as i am such a javascript noob! so please bear with my while i try to explain my problem... i've isolated the javascripts to this page > http://nang-nang.net/tumblr/blog/help.html in this example the plant image is using lightbox 2 and the bird.gif is using prototip2 to create a tooltip (that displays my latest tweet) (i should mention that these scripts will be used to pimp out my tumblr blog/portfolio http://bubblejam.tumblr.com eventually) the problem: i need the tooltip to stay put! i've managed to put the bird in a <div style="position:fixed..." etc so that's fine. but the tooltip isn't fixed and moves as the page scrolls down! can anyone take a look at what javascript i've got so far and fingers crossed there's a simple solution! thanks!! Hi I would like to use javascript to control what tooltip displays when a tab is rolled over depending on which tab was clicked. Code: <li id='1tab_1a' class='selected'><a id='1link_1a' title="Customer Info Screen"><span >Customer Info</span></a></li> <li id='1tab_1b' ><a id='1link_1b' title="Order Detail" ><span>Order</span></a></li> <li id='1tab_1c' ><a id='1link_1c' title="Phone Detail" ><span>Phone: 7093521232</span></a></li> For example when the Customer Info tab is selected I would like the tooltips to be like above but when Order is the tab selected I would like the tooltip to say Customer Info Detail, Order Detail Screen, and Phone Detail. How could I use an onclick event to control what tooltip is being displayed depending on which tab is selected? I have about 20 sets of customer info and sometimes not everyone contains all of the tabs and I would also like to be able to add more customers. |