Permalink
Browse files

save img

  • Loading branch information...
1 parent fef5815 commit 7174ed2dfdaa701f47201852e0ce3857dc2c2fe7 Fan Yu committed Aug 9, 2012
View
Binary file not shown.
View
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title></title>
+</head>
+<body>
+ <script type="text/javascript">
+ var color = new Array('red', 'blue', 'yellow', 'black');
+ var color2 = color.slice(1, 2);
+ //color.splice(1, 2);
+ //color.splice(2, 0, 'brown', 'pink');
+ color.splice(2, 2, 'brown', 'pink');
+ alert(color);
+ </script>
+</body>
+</html>
View
@@ -0,0 +1,43 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta name="author" content="Chomo" />
+ <title>根据内容宽度、高度自适应,垂直水平居中,内容高度超过窗体时,垂直居顶</title>
+ <style type="text/css">
+ html { height:100%;}
+ body { height:100%; text-align:center;}
+ .centerDiv {
+ display:inline-block;
+ zoom:1;
+ *display:inline;
+ vertical-align:middle;
+ text-align:left;
+ width:200px;
+ padding:10px;
+ border:1px solid #f60;
+ background:#fc0;}
+ .hiddenDiv {
+ height:100%;
+ overflow:hidden;
+ display:inline-block;
+ width:1px;
+ margin-left:-1px;
+ zoom:1;
+ *display:inline;
+ *margin-top:-1px;
+ margin-top:0;
+ vertical-align:middle;
+ background-color: #CC6699;}
+ </style>
+</head>
+<body>
+ <div class="centerDiv">
+ ss
+ </div>
+ <div class="hiddenDiv">
+ </div>
+ <div style="">
+ </div>
+</body>
+</html>
View
@@ -2,38 +2,67 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
- <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
+ <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script src="Scripts/float.js" type="text/javascript"></script>
+ <script src="Scripts/ImageListDebug.js" type="text/javascript"></script>
</head>
<body>
+ <div>
+ <div id="msgBox" style="height: 20px">
+ </div>
+ <img src="images/fry.jpg" />
+ <a href="http://pic002.cnblogs.com/images/2012/429355/2012080820270130.jpg" title="Download"
+ download>test download for chrome</a>
+ </div>
+ <script type="text/javascript">
+ function showImgSaveBtn(img) {
+ var btn = $(img).next();
+ if (btn && btn.html() == "save") {
+ btn.show();
+ }
+ else {
+ var offset = $(img).offset();
+ var w = $(img).outerWidth(false);
+ var h = $(img).outerHeight(false);
+ $("<div/>").css({
+ background: "orange",
+ width: "40px",
+ height: "20px",
+ position: "absolute",
+ top: offset.top + h - 20 + "px",
+ left: offset.left + w + "px",
+ cursor: "pointer",
+ textAlign: "center"
+ }).html("save").bind("click", function () { download(img.src); }).hover(function (event) {
+ $(this).show();
+ $(img).css("border", "5px solid orange");
+ },
+ function (event) {
+ $(this).hide();
+ $(img).css("border", "");
+ }).insertAfter($(img));
+ }
- <a href="http://pic002.cnblogs.com/images/2012/429355/2012080820270130.jpg" title="Download" download>test download for chrome</a>
- <script type="text/javascript">
- var imgs = [];
- var images = [];
- $("img").each(function (index) {
- imgs.push(this);
- });
- $(imgs).each(function (index) {
- images.push(this.src);
- });
-
+ }
- var images_container = document.getElementById('image_downloader_images_container');
- if (!images_container) {
- images_container = document.createElement('div');
- images_container.id = 'image_downloader_images_container';
- images_container.style.display = 'none';
+ function hideImgSaveBtn(img) {
+ var btn = $(img).next();
+ if (btn && btn.html() == "save") {
+ btn.hide();
}
- document.body.appendChild(images_container);
+ }
- for (var i in images) {
- var anchor = document.createElement('a');
- anchor.href = images[i];
- anchor.download = '';
- images_container.appendChild(anchor);
- anchor.click();
- }
- </script>
+ function addborder(event) {
+ $(this).css("border", "5px solid orange");
+ showImgSaveBtn(this);
+ }
+ function removeborder(event) {
+ $(this).css("border", "");
+ hideImgSaveBtn(this);
+ }
+ //$("img").after($("<p/>").html("hello"));
+ // $("<img/>").attr("src", "images/icon_save.png").insertAfter($("img"));
+ $($("img").hover(addborder, removeborder));
+ </script>
</body>
-</html>
+</html>
@@ -51,11 +51,15 @@
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
+ <Content Include="ArrayTest.htm" />
<Content Include="default.htm" />
+ <Content Include="DivTest.htm" />
<Content Include="images\fry.jpg" />
<Content Include="images\icon.gif" />
<Content Include="ImageList.htm" />
+ <Content Include="images\icon_save.png" />
<Content Include="Scripts\float.js" />
+ <Content Include="Scripts\ImageListDebug.js" />
<Content Include="Scripts\jquery-1.4.1-vsdoc.js" />
<Content Include="Scripts\jquery-1.4.1.js" />
<Content Include="Scripts\jquery-1.4.1.min.js" />
@@ -0,0 +1,40 @@
+//var imgs = [];
+//var images = [];
+//$("img").each(function (index) {
+// imgs.push(this);
+//});
+//$(imgs).each(function (index) {
+// images.push(this.src);
+//});
+
+//var images_container = document.getElementById('image_downloader_images_container');
+//if (!images_container) {
+// images_container = document.createElement('div');
+// images_container.id = 'image_downloader_images_container';
+// images_container.style.display = 'none';
+//}
+//document.body.appendChild(images_container);
+
+// for (var i in images) {
+// var anchor = document.createElement('a');
+// anchor.href = images[i];
+// anchor.download = '';
+// images_container.appendChild(anchor);
+// anchor.click();
+// }
+
+function download(imgurl) {
+ var images_container = document.getElementById('image_downloader_images_container');
+ if (!images_container) {
+ images_container = document.createElement('div');
+ images_container.id = 'image_downloader_images_container';
+ images_container.style.display = 'none';
+ }
+ document.body.appendChild(images_container);
+
+ var anchor = document.createElement('a');
+ anchor.href = imgurl;
+ anchor.download = '';
+ images_container.appendChild(anchor);
+ anchor.click();
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7174ed2

Please sign in to comment.