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 -
<table width="100%" border="0" cellspacing="3" cellpadding="3">
-
<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>
-
<tr><td><a href="products/flowers/bunch-of-lillies" title="Details" class="normal">Bunch of Lillies</a></td></tr>
-
</table>
-
here is Javascript file -
this.imagePreview = function(){
-
/* CONFIG */
-
xOffset = 10;
-
yOffset = 30;
-
// these 2 variable determine popup's distance from the cursor
-
// you might want to adjust to get the right result
-
/* END CONFIG */
-
$("a.preview").hover(function(e){
-
this.t = this.title;
-
this.title = "";
-
var c = (this.t != "") ? "<br /><br />" + this.t : "";
-
$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");
-
$("#preview")
-
.css("top",(e.pageY - xOffset) + "px")
-
.css("left",(e.pageX + yOffset) + "px")
-
.fadeIn("fast");
-
},
-
function(){
-
this.title = this.t;
-
$("#preview").remove();
-
});
-
$("a.preview").mousemove(function(e){
-
$("#preview")
-
.css("top",(e.pageY - xOffset) + "px")
-
.css("left",(e.pageX + yOffset) + "px");
-
});
-
};
-
-
#preview{
-
border-radius:5px;
-
-moz-border-radius: 5px;
-
-webkit-border-radius: 5px;
-
position:absolute;
-
border:1px solid #ccc;
-
background:#333;
-
padding:10px;
-
display:none;
-
color:#fff;
-
}
-
here is the LIVE URL
If some one fixed this issue, i will be very grateful to him/her.
Thanks in advance
5 1665
Give your detail URL an ID and then set the href of the preview link to its href, e.g. - ... = $("#detailLink").href;
I assigned the id to my detail URL like this way -
<table width="100%" border="0" cellspacing="3" cellpadding="3">
-
<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>
-
<tr><td><a href="products/vtr-storage/sony-dsr-45ap" title="Details" class="normal">Sony DSR-45AP</a></td></tr>
-
</table>
-
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 -
this.imagePreview = function(){
-
/* CONFIG */
-
xOffset = 10;
-
yOffset = 30;
-
// these 2 variable determine popup's distance from the cursor
-
// you might want to adjust to get the right result
-
/* END CONFIG */
-
$("a.preview").hover(function(e){
-
this.t = this.title;
-
this.title = "";
-
var c = (this.t != "") ? "<br /><br />" + this.t : "";
-
$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");
-
$("#preview")
-
.css("top",(e.pageY - xOffset) + "px")
-
.css("left",(e.pageX + yOffset) + "px")
-
.fadeIn("fast");
-
},
-
function(){
-
this.title = this.t;
-
$("#preview").remove();
-
});
-
$("a.preview").mousemove(function(e){
-
$("#preview")
-
.css("top",(e.pageY - xOffset) + "px")
-
.css("left",(e.pageX + yOffset) + "px");
-
});
-
};
-
In above code, this is the line where it assigning preview href. - $("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
Surely the second link should be "detailLink". This is the href that you want to set the first one to, isn't it?
No it is'nt. I think you did not get me. Well let me explain my problem again.
Here is my html code -
<table width="100%" border="0" cellspacing="3" cellpadding="3">
-
<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>
-
</table>
-
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
Add an onclick to change the href to the detail link.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
by: Ulysse |
last post by:
Hello,
I need to clean the string like this :
string =
"""
bonne mentalité mec!:) \n <br>bon pour
info moi je suis un serial posteur arceleur dictateur ^^*
\n ...
|
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...
|
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
|
by: manchin2 |
last post by:
Hi,
Can anybody please provide the information about """ and its use, if possible please provide an example.
...
|
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":
...
|
by: jmash |
last post by:
Suppose I have the following string whch is part of an xml string:
String s= "Script Id="Test" "
And I need to get
s= "Script Id="Test" "
Can anyone tell me how this can acheived?
...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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,...
| |