473,395 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

customised "a" link redirect to a URL

245 100+
Hi geeks,
I am stuck in a JavaScript function. Actually when we take a mouse over the picture it shows tooltip (image and title text). The href is path to the location of image. But what i want to show the tooltip (image and title text) as well as to set the href path to detail page link. I am unable to customized it. Can somebody help me out to fix this issue.
Here is my HTML code

Expand|Select|Wrap|Line Numbers
  1. <table width="100%" border="0" cellspacing="3" cellpadding="3">
  2.     <tr><td align="left" valign="middle"><a href="http://bytes.com/images/products/1207730720_lillies.jpg"  class="preview" title="Bunch of Lillies"><img src="http://bytes.com/images/products/1207730720_lillies.jpg" width="75" height="75" alt="Bunch of Lillies" class="img-border" /></a></td></tr>
  3.     <tr><td><a href="products/flowers/bunch-of-lillies" title="Details" class="normal">Bunch of Lillies</a></td></tr>
  4. </table>
  5.  
here is Javascript file

Expand|Select|Wrap|Line Numbers
  1. this.imagePreview = function(){    
  2.     /* CONFIG */
  3.     xOffset = 10;
  4.     yOffset = 30;
  5.     // these 2 variable determine popup's distance from the cursor
  6.     // you might want to adjust to get the right result
  7.     /* END CONFIG */
  8.     $("a.preview").hover(function(e){
  9.         this.t = this.title;
  10.         this.title = "";    
  11.         var c = (this.t != "") ? "<br /><br />" + this.t : "";
  12.         $("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");                                 
  13.         $("#preview")
  14.             .css("top",(e.pageY - xOffset) + "px")
  15.             .css("left",(e.pageX + yOffset) + "px")
  16.             .fadeIn("fast");                        
  17.     },
  18.     function(){
  19.         this.title = this.t;    
  20.         $("#preview").remove();
  21.     });    
  22.     $("a.preview").mousemove(function(e){
  23.         $("#preview")
  24.             .css("top",(e.pageY - xOffset) + "px")
  25.             .css("left",(e.pageX + yOffset) + "px");
  26.     });
  27. };
  28.  
Expand|Select|Wrap|Line Numbers
  1. #preview{
  2.     border-radius:5px;
  3.     -moz-border-radius: 5px;
  4.     -webkit-border-radius: 5px;
  5.     position:absolute;
  6.     border:1px solid #ccc;
  7.     background:#333;
  8.     padding:10px;
  9.     display:none;
  10.     color:#fff;
  11. }
  12.  
here is the LIVE URL

If some one fixed this issue, i will be very grateful to him/her.
Thanks in advance
Jul 22 '10 #1
5 1665
acoder
16,027 Expert Mod 8TB
Give your detail URL an ID and then set the href of the preview link to its href, e.g.
Expand|Select|Wrap|Line Numbers
  1.  ... = $("#detailLink").href;
Jul 23 '10 #2
neovantage
245 100+
I assigned the id to my detail URL like this way
Expand|Select|Wrap|Line Numbers
  1. <table width="100%" border="0" cellspacing="3" cellpadding="3">
  2. <tr><td align="left" valign="middle"><a href="images/products/n_1279886753.gif" id="detailLink" class="preview" title="Sony DSR-45AP"><img src="images/products/t_1279886752.gif" width="75" height="75" alt="Sony DSR-45AP" class="img-border" /></a></td></tr>
  3. <tr><td><a href="products/vtr-storage/sony-dsr-45ap" title="Details" class="normal">Sony DSR-45AP</a></td></tr>
  4. </table>
  5.  
But i am unable to understand the detail id href to it's actual href. Where should i assigned that id.

Here is my javascript code
Expand|Select|Wrap|Line Numbers
  1. this.imagePreview = function(){    
  2.     /* CONFIG */
  3.     xOffset = 10;
  4.     yOffset = 30;
  5.     // these 2 variable determine popup's distance from the cursor
  6.     // you might want to adjust to get the right result
  7.     /* END CONFIG */
  8.     $("a.preview").hover(function(e){
  9.         this.t = this.title;
  10.         this.title = "";    
  11.         var c = (this.t != "") ? "<br /><br />" + this.t : "";
  12.         $("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");                                 
  13.         $("#preview")
  14.             .css("top",(e.pageY - xOffset) + "px")
  15.             .css("left",(e.pageX + yOffset) + "px")
  16.             .fadeIn("fast");                        
  17.     },
  18.     function(){
  19.         this.title = this.t;    
  20.         $("#preview").remove();
  21.     });    
  22.     $("a.preview").mousemove(function(e){
  23.         $("#preview")
  24.             .css("top",(e.pageY - xOffset) + "px")
  25.             .css("left",(e.pageX + yOffset) + "px");
  26.     });
  27. };
  28.  
In above code, this is the line where it assigning preview href.
Expand|Select|Wrap|Line Numbers
  1. $("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");
But how can i assigned detail id href to preview link href
Jul 23 '10 #3
acoder
16,027 Expert Mod 8TB
Surely the second link should be "detailLink". This is the href that you want to set the first one to, isn't it?
Jul 24 '10 #4
neovantage
245 100+
No it is'nt. I think you did not get me. Well let me explain my problem again.

Here is my html code
Expand|Select|Wrap|Line Numbers
  1. <table width="100%" border="0" cellspacing="3" cellpadding="3">
  2. <tr><td align="left" valign="middle"><a href="images/products/n_1279886753.gif" id="detailLink" class="preview" title="Sony DSR-45AP"><img src="images/products/t_1279886752.gif" width="75" height="75" alt="Sony DSR-45AP" class="img-border" /></a></td></tr>
  3. </table>
  4.  
The href of above written link is the path of the image which use for preview. But when i clicked on that link then it opens the image.
But what i want that when i clicked on that image it does not open the image instead it takes to the detail page of the product. I have the detail link value but it's href already point to the path of image how can i redirect to it's detail page though i have the detail link value
Jul 24 '10 #5
acoder
16,027 Expert Mod 8TB
Add an onclick to change the href to the detail link.
Jul 27 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
2
by: steve | last post by:
Hi, I need to do conditional script "include", but like to pull the code from db instead of a file. How do I do that? Reason: I like to implement some complex regex logic, and make it table...
8
by: msnews.microsoft.com | last post by:
I want to redirect the user to a url outside of our website but I want it to preserve our application's window by opening a new window. We have a datagrid that has five hyperlink columns containing...
8
by: Ulysse | last post by:
Hello, I need to clean the string like this : string = """ bonne mentalit&eacute; mec!:) \n <br>bon pour info moi je suis un serial posteur arceleur dictateur ^^* \n ...
2
by: Angus | last post by:
I am trying to change the selection in Javascript - but this HTML element is not a standard option control. On the web page it looks like a dropdown list - and you click on the right hand down...
5
by: Maria Sudderman | last post by:
I have a prblem with the "onClick" command. onClick="insert('<a href="URI">', '</a>')"> but this is not correct! why? Maria
1
by: manchin2 | last post by:
Hi, Can anybody please provide the information about "&quot" and its use, if possible please provide an example. ...
4
by: thaytu888888 | last post by:
Here is my codes in aspx page: <td colspan="2" class="main_menu" runat="server" onclick='toggleDisplay(<%#Eval("description")%>);'><%#Eval("description")%></td> Here is in "View source": ...
2
by: jmash | last post by:
Suppose I have the following string whch is part of an xml string: String s= "Script Id=&quot;Test&quot; " And I need to get s= "Script Id="Test" " Can anyone tell me how this can acheived? ...
1
by: silverachilles | last post by:
Hello, I have php code which takes an rss feed and outputs it on a page of my website. For each item it shows the link, title and description. My problem is the description element contains a lot...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.