asp.net with JS to achieve the mouse to small map, automatic display corresponding large map _ practical skills

Source: Internet
Author: User
Implementation according to the background binding small picture, mouse move to small map, automatic display corresponding large image

. NET Compact version

<script language= "JavaScript" >
function Getshowimg (imgfile)
{
document.all ("ShowImage"). src = "/semir/images/" + imgfile;

}
</script>
DataList binding
<asp:datalist id= "Dlsides" runat= "Server" onitemcommand= "Dlsides_itemcommand" repeatdirection= "Horizontal"
repeatcolumns= "3" datakeyfield= "Sideid" cssclass= "Semirtext" >
<ItemTemplate>
<a onmouseover= "getshowimg (' <%# databinder.eval (Container.DataItem, Sidepath")%> ') "> ' border=0 ></a>
</ItemTemplate>
</asp:datalist>


Display the corresponding large image


ASP full version

<script language= "JavaScript" >
function Imagepreload ()
{
var args = imagepreload.arguments;
Document. Imgprearray = new Array (args.length);
for (var i=0; i<args.length; i++)
{
Document. Imgprearray[i] = new Image;
Document. IMGPREARRAY[I].SRC = "admin/upfile/newbook/" + args[i];
}
}
function Fitsize () {
var a, B;
var imgobj = document.all ("ShowImage");
var oldimg = new Image ();
OLDIMG.SRC = IMGOBJ.SRC;
var dw = Oldimg.width;
var dh = oldimg.height;
if (imgobj = = null) {
SetTimeout ("Fitsize ()", 50);
Return
}
if (Imgobj.offsetwidth = = 0) {
SetTimeout ("Fitsize ()", 50);
Return
}
var maxw = 300;
var maxh = 270;
if (Dw>maxw | | dh>maxh) {
A = DW/MAXW;
b = Dh/maxw;
if (b>a) a=b;
DW = dw/a;
DH = dh/a;
}
if (DW > 0 && dh > 0) {
Imgobj.width = DW;
Imgobj.height = DH;
}
}
function getshowimg (Imgtext, Imgfile) {
document.all ("Showimgtext"). InnerHTML = Imgtext;
document.all ("ShowImage"). src = "admin/upfile/newbook/" + imgfile;
document.all ("ShowImage"). width = 267;
document.all ("ShowImage"). Height = 267;
Fitsize (); ' Show picture size
}
function Showtextdetail (n) {
For (I=1 i<5; i++) {
document.all ("Textdetail" +i). Style.display = "None";
}
document.all ("Textdetail" +n). Style.display = "";
For (I=1 i<4; i++) {
document.all ("Titledetail" +i). ClassName = "Shoptaboff";
}
if (n < 4) {
document.all ("Titledetail" +n). ClassName = "Shoptabon";
}
}
</script>
<script language= "JavaScript" for= "window" event= "onload" >
Imagepreload (' <%=rs ("picture")%> ');
</script>
'---------Call-display-------
<%if rs ("picture") <> "" Then%>
<a style= "Cursor:hand" >
"border=" 0 "width=" 267 "height=" 267 " >
<!---->
</a> <span id= "Showimgtext" style= "font-weight:bold;" ></span>
<% End If%>
'--------------the mouse over the picture------
<% if RS ("picture") <> "then%>
<a onmouseover= "getshowimg (", "<%=rs (" picture ")%> '); >
"alt=" Dogo "width=" "height=" border= " "0" ></a>
<%end if%>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.