Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 亚洲依依成人综合网址首页,日本三级视频在线观看,色女孩综合网

          整合營(yíng)銷服務(wù)商

          電腦端+手機(jī)端+微信端=數(shù)據(jù)同步管理

          免費(fèi)咨詢熱線:

          html實(shí)現(xiàn)點(diǎn)擊圖片放大功能

          <html>
              <head>
                  <style>
                      .over {position: fixed; left:0; top:0; width:100%; z-index:100;}
                      .tempContainer {position:fixed; width:100%; margin-right:0px; margin-left:0px; text-align:center; z-index:101;}
                  </style>
                  <script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
              </head>
              <body>
                  <div class="over"></div><!--背景層-->
                  <div class="logoImg amplifyImg"><!--注意:此處的amlifyImg不可少-->
                      < img src="test.jpg"/><!-- 此處是引入圖片的路徑 -->
                  </div>
                  <script>
                      $(document).ready(function () {
                          var imgsObj = $('.amplifyImg img');//需要放大的圖像
                          if(imgsObj){
                              $.each(imgsObj,function(){
                                  $(this).click(function(){
                                      var currImg = $(this);
                                      coverLayer(1);
                                      var tempContainer = $('<div class=tempContainer></div>');//圖片容器
                                      with(tempContainer){//width方法等同于$(this)
                                          appendTo("body");
                                          var windowWidth=$(window).width();
                                          var windowHeight=$(window).height();
                                          //獲取圖片原始寬度、高度
                                          var orignImg = new Image();
                                          orignImg.src =currImg.attr("src") ;
                                          var currImgWidth= orignImg.width;
                                          var currImgHeight = orignImg.height;
                                          if(currImgWidth<windowWidth){//為了讓圖片不失真,當(dāng)圖片寬度較小的時(shí)候,保留原圖
                                              if(currImgHeight<windowHeight){
                                                  var topHeight=(windowHeight-currImgHeight)/2;
                                                  if(topHeight>35){/*此處為了使圖片高度上居中顯示在整個(gè)手機(jī)屏幕中:因?yàn)樵赼ndroid,ios的微信中會(huì)有一個(gè)title導(dǎo)航,35為title導(dǎo)航的高度*/
                                                      topHeight=topHeight-35;
                                                      css('top',topHeight);
                                                  }else{
                                                      css('top',0);
                                                  }
                                                  html('< img border=0 src=' + currImg.attr('src') + '>');
                                              }else{
                                                  css('top',0);
                                                  html('< img border=0 src=' + currImg.attr('src') + ' height='+windowHeight+'>');
                                              }
                                          }else{
                                              var currImgChangeHeight=(currImgHeight*windowWidth)/currImgWidth;
                                              if(currImgChangeHeight<windowHeight){
                                                  var topHeight=(windowHeight-currImgChangeHeight)/2;
                                                  if(topHeight>35){
                                                      topHeight=topHeight-35;
                                                      css('top',topHeight);
                                                  }else{
                                                      css('top',0);
                                                  }
                                                  html('< img border=0 src=' + currImg.attr('src') + ' width='+windowWidth+';>');
                                              }else{
                                                  css('top',0);
                                                  html('< img border=0 src=' + currImg.attr('src') + ' width='+windowWidth+'; height='+windowHeight+'>');
                                              }
                                          }
                                      }
                                      tempContainer.click(function(){
                                          $(this).remove();
                                          coverLayer(0);
                                      });
                                  });
                              });
                          }
                          else{
                              return false;
                          }
                          //使用禁用蒙層效果
                          function coverLayer(tag){
                              with($('.over')){
                                  if(tag==1){
                                      css('height',$(document).height());
                                      css('display','block');
                                      css('opacity',1);
                                      css("background-color","#FFFFFF");
                                      css("background-color","rgba(0,0,0,0.7)" );  //蒙層透明度
                                  }
                                  else{
                                      css('display','none');
                                  }
                              }
                          }
                      });
                  </script>
              </body>
          </html>

          先使用jQuery選擇器獲取到想要綁定click事件的img元素,然后可以直接綁定click方法,也可以通過(guò)bind方法綁定。這里詳細(xì)介紹一下bind方法。jQuery 事件 - bind() 方法 —— 定義和用法

          html中如何給圖片添加點(diǎn)擊事件的詳解


          bind() 方法為被選元素添加一個(gè)或多個(gè)事件處理程序,并規(guī)定事件發(fā)生時(shí)運(yùn)行的函數(shù)。

          jQuery 事件 - bind() 方法 ——將事件和函數(shù)綁定到元素

          規(guī)定向被選元素添加的一個(gè)或多個(gè)事件處理程序,以及當(dāng)事件發(fā)生時(shí)運(yùn)行的函數(shù)。

          jQuery 事件 - bind() 方法——語(yǔ)法

          1 $(selector).bind(event,data,function)

          jQuery 事件 - bind() 方法——參數(shù)描述

          event 必需。規(guī)定添加到元素的一個(gè)或多個(gè)事件。由空格分隔多個(gè)事件。必須是有效的事件。

          data 可選。規(guī)定傳遞到函數(shù)的額外數(shù)據(jù)。

          function 必需。規(guī)定當(dāng)事件發(fā)生時(shí)運(yùn)行的函數(shù)。

          實(shí)例:


          1 //直接給所有img標(biāo)簽綁定click事件

          2 $("img").click(function(){

          3 alert('你點(diǎn)擊了圖片');

          4 })

          5

          6 //使用bind方法綁定click事件

          7 $("img").bind("click",function(){

          8 alert('你點(diǎn)擊了圖片');

          9 })


          Html 的img標(biāo)簽添加點(diǎn)擊事件


          1 package com.topnews;

          2

          3 import java.util.ArrayList;

          4

          5 import android.annotation.SuppressLint;

          6 import android.app.Activity;

          7 import android.app.Fragment;

          8 import android.content.Context;

          9 import android.content.Intent;

          10 import android.graphics.Bitmap;

          11 import android.os.AsyncTask;

          12 import android.os.Bundle;

          13 import android.text.TextUtils;

          14 import android.util.Log;

          15 import android.view.View;

          16 import android.view.ViewGroup.LayoutParams;

          17 import android.webkit.WebChromeClient;

          18 import android.webkit.WebSettings;

          19 import android.webkit.WebView;

          20 import android.webkit.WebViewClient;

          21 import android.webkit.WebSettings.LayoutAlgorithm;

          22 import android.widget.Button;

          23 import android.widget.FrameLayout;

          24 import android.widget.ProgressBar;

          25 import android.widget.TextView;

          26

          27 import com.topnews.base.BaseActivity;

          28 import com.topnews.bean.NewsEntity;

          29 import com.topnews.service.NewsDetailsService;

          30 import com.topnews.tool.BaseTools;

          31 import com.topnews.tool.DataTools;

          32 import com.topnews.tool.DateTools;

          33

          34 @SuppressLint("JavascriptInterface")

          35 public class DetailsActivity extends BaseActivity {

          36 private TextView title;

          37 private ProgressBar progressBar;

          38 private FrameLayout customview_layout;

          39 private String news_url;

          40 private String news_title;

          41 private String news_source;

          42 private String news_date;

          43 private NewsEntity news;

          44 private TextView action_comment_count;

          45 WebView webView;

          46

          47 @Override

          48 protected void onCreate(Bundle savedInstanceState) {

          49 // TODO Auto-generated method stub

          50 super.onCreate(savedInstanceState);

          51 setContentView(R.layout.details);

          52 setNeedBackGesture(true);// 設(shè)置需要手勢(shì)監(jiān)聽(tīng)

          53 getData();

          54 initView();

          55 initWebView();

          56 }

          57

          58 /* 獲取傳遞過(guò)來(lái)的數(shù)據(jù) */

          59 private void getData() {

          60 news = (NewsEntity) getIntent().getSerializableExtra("news");

          61 news_url = news.getSource_url();

          62 news_title = news.getTitle();

          63 news_source = news.getSource();

          64 news_date = 65DateTools.getNewsDetailsDate(String.valueOf(news.getPublishTime()));

          66 }

          67

          68 private void initWebView() {

          69 webView = (WebView) findViewById(R.id.wb_details);

          70 LayoutParams params = new 71LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

          72 if (!TextUtils.isEmpty(news_url)) {

          73 WebSettings settings = webView.getSettings();

          74 settings.setJavaScriptEnabled(true);// 設(shè)置可以運(yùn)行JS腳本

          75 // settings.setTextZoom(120);//Sets the text zoom of the page in

          76 // percent. The default is 100.

          77 settings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

          78 // settings.setUseWideViewPort(true); //打開(kāi)頁(yè)面時(shí), 自適應(yīng)屏幕

          79 // settings.setLoadWithOverviewMode(true);//打開(kāi)頁(yè)面時(shí), 自適應(yīng)屏幕

          80 settings.setSupportZoom(false);// 用于設(shè)置webview放大

          81 settings.setBuiltInZoomControls(false);

          82 webView.setBackgroundResource(R.color.transparent);

          83 // 添加js交互接口類,并起別名 imagelistner

          84 webView.addJavascriptInterface(new 85JavascriptInterface(getApplicationContext()), "imagelistner");

          86 webView.setWebChromeClient(new MyWebChromeClient());

          87 webView.setWebViewClient(new MyWebViewClient());

          88 Log.i("info", "news_url:" + news_url);

          89 Log.i("info", "news_title:" + news_title);

          90 Log.i("info", "news_source:" + news_source);

          91 Log.i("info", "news_date:" + news_date);

          92 new MyAsnycTask().execute(news_url, news_title, news_source + " " + 93news_date);

          94 }

          95 }

          96

          97 private void initView() {

          98 title = (TextView) findViewById(R.id.title);

          99 progressBar = (ProgressBar) findViewById(R.id.ss_htmlprogessbar);

          100 customview_layout = (FrameLayout) 101findViewById(R.id.customview_layout);

          102 // 底部欄目

          103 action_comment_count = (TextView) 104findViewById(R.id.action_comment_count);

          105

          106 progressBar.setVisibility(View.VISIBLE);

          107 title.setTextSize(13);

          108 title.setVisibility(View.VISIBLE);

          109 title.setText(news_url);

          110 action_comment_count.setText(String.valueOf(news.getCommentNum()));

          111 }

          112

          113 @Override

          114 public void onBackPressed() {

          115 super.onBackPressed();

          116 overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);

          117 }

          118

          119 private class MyAsnycTask extends AsyncTask<string, string,="" string=""> {

          120

          121 @Override

          122 protected String doInBackground(String... urls) {

          123 String data = NewsDetailsService.getNewsDetails(urls[0], urls[1], urls[2]);

          124 Log.i("info", "MyAsnycTask.data:" + data);

          125 return data;

          126 }

          127

          128 @Override

          129 protected void onPostExecute(String data) {

          130 webView.loadDataWithBaseURL(null, data, "text/html", "utf-8", null);

          131 }

          132 }

          133

          134 // 注入js函數(shù)監(jiān)聽(tīng)

          135 private void addImageClickListner() {

          136 // 這段js函數(shù)的功能就是,遍歷所有的img幾點(diǎn),并添加onclick函數(shù),在還是執(zhí)137 行的時(shí)候調(diào)用本地接口傳遞url過(guò)去

          138 webView.loadUrl("javascript:(function(){" + "var objs = 139document.getElementsByTagName(\"img\");" + "var imgurl=''; "

          140 + "for(var i=0;i<objs.length;i++) "="" +="" "{"="" 141"imgurl+="objs[i].src+',';"" objs[i].onclick="function()" {="" 142window.imagelistner.openimage(imgurl);="" }="" "}"="" "})()");="" js通信接口="" 143public="" class="" javascriptinterface="" private="" context="" context;="" 144javascriptinterface(context="" context)="" this.context="context;" void="" 145openimage(string="" img)="" string[]="" imgs="img.split(",");" 146arraylist<string=""> imgsUrl = new ArrayList<string>();

          147 for (String s : imgs) {

          148 imgsUrl.add(s);

          149 Log.i("圖片的URL>>>>>>>>>>>>>>>>>>>>>>>", s);

          150 }

          151 Intent intent = new Intent();

          152 intent.putStringArrayListExtra("infos", imgsUrl);

          153 intent.setClass(context, ImageShowActivity.class);

          154 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

          155 context.startActivity(intent);

          156 }

          157 }

          158

          159 // 監(jiān)聽(tīng)

          160 private class MyWebViewClient extends WebViewClient {

          161 @Override

          162 public boolean shouldOverrideUrlLoading(WebView view, String url) {

          163 return super.shouldOverrideUrlLoading(view, url);

          164 }

          165

          166 @Override

          167 public void onPageFinished(WebView view, String url) {

          168 view.getSettings().setJavaScriptEnabled(true);

          169 super.onPageFinished(view, url);

          170 // html加載完成之后,添加監(jiān)聽(tīng)圖片的點(diǎn)擊js函數(shù)

          171 addImageClickListner();

          172 progressBar.setVisibility(View.GONE);

          173 webView.setVisibility(View.VISIBLE);

          174 }

          175

          176 @Override

          177 public void onPageStarted(WebView view, String url, Bitmap favicon) {

          178 view.getSettings().setJavaScriptEnabled(true);

          179 super.onPageStarted(view, url, favicon);

          180 }

          181

          182 @Override

          183 public void onReceivedError(WebView view, int errorCode, String description, 184String failingUrl)

          185 {

          progressBar.setVisibility(View.GONE);

          super.onReceivedError(view, errorCode, description, failingUrl);

          }

          }

          private class MyWebChromeClient extends WebChromeClient {

          @Override

          public void onProgressChanged(WebView view, int newProgress) {

          // TODO Auto-generated method stub

          if (newProgress != 100) {

          progressBar.setProgress(newProgress);

          }

          super.onProgressChanged(view, newProgress);

          }

          }

          }</string></objs.length;i++)></string,>


          // NewsDetailsService.java


          1 package com.topnews.service;

          2

          3 import java.io.IOException;

          4 import org.jsoup.Jsoup;

          5 import org.jsoup.nodes.Document;

          6 import org.jsoup.nodes.Element;

          7

          8 import android.text.TextUtils;

          9

          10 public class NewsDetailsService {

          11 public static String getNewsDetails(String url, String news_title,

          12 String news_date) {

          13 Document document = null;

          14 String data = "" +

          15 "<center><h2 style="'font-size:16px;'">" + news_title + "</h2></center>";

          16 data = data + "<p align="'left'" style="'margin-left:10px'">"

          17 + "<span style="'font-size:10px;'">"

          18 + news_date

          19 + "</span>"

          20 + "</p>";

          21 data = data + "<hr size="'1'">";

          22 try {

          23 document = Jsoup.connect(url).timeout(9000).get();

          24 Element element = null;

          25 if (TextUtils.isEmpty(url)) {

          26 data = "";

          27 element = document.getElementById("memberArea");

          28 } else {

          29 element = document.getElementById("artibody");

          30 }

          31 if (element != null) {

          32 data = data + element.toString();

          33 }

          34 data = data + "";

          35 } catch (IOException e) {

          36 e.printStackTrace();

          37 }

          38 return data;

          39 }

          40 }

          以上就是html中如何給圖片添加點(diǎn)擊事件的詳解的詳細(xì)內(nèi)容,

          原理是點(diǎn)擊圖片時(shí),改變圖片的寬度和高度。

          下面是效果圖:

          1、未點(diǎn)擊時(shí)圖片

          未點(diǎn)擊時(shí)圖片


          2、點(diǎn)擊后的圖片

          點(diǎn)擊后的圖片

          HTML代碼:

          <img src="img/pic.jpg" id="images" width="100" height="100" />

          jQuery核心代碼:

          <script>

          $(document).ready(function() {

          var img = $(this),t = true;//當(dāng)t為true時(shí),是正常狀態(tài)下的

          $("#images").click(function() {

          if(t) {

          t = false;

          imgH = $(this).height(400);

          imgW = $(this).width(400);

          } else {

          t = true;

          imgH = $(this).height(100);

          imgW = $(this).width(100);

          }

          });

          });

          </script>


          主站蜘蛛池模板: 色欲AV无码一区二区三区| 国产精品高清视亚洲一区二区 | 一区二区亚洲精品精华液| 日韩高清一区二区三区不卡| 久久亚洲AV午夜福利精品一区| 精品无码成人片一区二区| 日韩一区二区超清视频| 久久久一区二区三区| 东京热无码av一区二区| 国产suv精品一区二区6| 精品欧美一区二区在线观看| 在线中文字幕一区| 亚洲av鲁丝一区二区三区| 日韩人妻无码一区二区三区久久99 | 国产视频一区在线播放| av无码免费一区二区三区| 少妇无码一区二区二三区| 日韩人妻无码一区二区三区综合部 | 亚洲AV无码一区二区乱孑伦AS| 一区二区日韩国产精品| 国产精品一区二区综合| 中文字幕日韩欧美一区二区三区| 亚洲一区二区三区免费在线观看| 无码人妻精品一区二区| 一区二区三区在线|欧| 久久精品一区二区| 久久一本一区二区三区| 日本一区二区在线播放| 日本一区二区在线播放| 亚洲av成人一区二区三区在线播放| 亚洲国产精品一区二区久| 亚洲AV噜噜一区二区三区| 无码人妻一区二区三区av| 国产日韩精品一区二区在线观看| 日韩精品电影一区| 成人在线视频一区| 亚洲乱码一区二区三区在线观看 | 日韩成人无码一区二区三区| 国产激情一区二区三区小说| 日韩美女视频一区| 国产成人一区二区三区在线|