在html中添加img src标记的click事件

时间:2015-05-04 06:03:31

标签: javascript html

我是HTML新手,

我有2个HTML网页<div class="container-fluid"> <div style="border-style: solid;padding:1%;" class="col-md-2 col-md-offset-1"> <div class="row"> <div class="col-md-7"> <h4>Title</h4> <p>Name</p> <p>Family</p> </div> <div class="col-md-5"> <img class="img-responsive" src="www.example.com/photo"> </div> </div> <div class="row"> <p> Description </p> </div> </div> <div style="border-style: solid;padding:1%" class="col-md-2"> <div class="row"> <div class="col-md-7"> <h4>Title</h4> <p>Name</p> <p>Family</p> </div> <div class="col-md-5"> <img class="img-responsive" src="www.example.com/photo"> </div> </div> <div class="row"> <p> Description </p> </div> </div> <div style="border-style: solid;padding:1%" class="col-md-2"> <div class="row"> <div class="col-md-7"> <h4>Title</h4> <p>Name</p> <p>Family</p> </div> <div class="col-md-5"> <img class="img-responsive" src="www.example.com/photo"> </div> </div> <div class="row"> <p> Description </p> </div> </div> <div style="border-style: solid;padding:1%" class="col-md-2"> <div class="row"> <div class="col-md-7"> <h4>Title</h4> <p>Name</p> <p>Family</p> </div> <div class="col-md-5"> <img class="img-responsive" src="www.example.com/photo"> </div> </div> <div class="row"> <p> Description </p> </div> </div> </div> page1

第1页:

Page2

点击上一个img <html> <head> <title>IOS_landing_V02</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <!-- Save for Web Slices (IOS_landing_V02.psd) --> <table id="Table_01" width="1024" height="768" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img src="IOS_landing_V02_01.jpg" width="1024" height="20" alt=""></td> </tr> <tr> <td> <img src="IOS_landing_V02_02.jpg" width="1024" height="112" alt=""></td> </tr> <tr> <td> <img src="IOS_landing_V02_03.jpg" width="1024" height="422" alt=""></td> </tr> <tr> <td> <img src="IOS_landing_V02_04.jpg" width="1024" height="1" alt=""></td> </tr> <tr> <td> <img src="IOS_landing_V02_05.jpg" width="1024" height="213" alt=""></td> </tr> </table> <!-- End Save for Web Slices --> </body> </html> 我想加载另一个HTMl页面,即(src="IOS_landing_V02_05.jpg")

怎么做?

4 个答案:

答案 0 :(得分:0)

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true"> <ImageButton android:id="@+id/imageButton” android:layout_width="40dip" android:layout_height="match_parent" android:background="@android:color/transparent" android:contentDescription="@string/descrp" android:scaleType="center" android:src="@drawable/some_drawable” android:visibility="visible" /> <TextView android:id="@+id/textview” android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="10dip" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:textColor="#FFFFFF" android:textStyle="bold" /> //changes <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ProgressBar android:id="@+id/some_other_id" style="?android:attr/progressBarStyleHorizontal" android:layout_width="match_parent" android:layout_height="10dp" android:layout_alignParentBottom="true" android:layout_marginBottom="-4dp" /> </RelativeLayout></RelativeLayout> 锚标记包裹您的img标记,该标记会重定向您。

a

答案 1 :(得分:0)

您可以这样做:使用<a>标记包裹您的图片,然后使用href属性添加指向第二页的链接。

<td>
        <a href="page2.html">  
            <img src="IOS_landing_V02_05.jpg" width="1024" height="213" alt="">  
       </a>  
</td>

答案 2 :(得分:0)

将最后一个img包裹在这样的链接中:

<a href="pathToPage2.html">
  <img src="IOS_landing_V02_05.jpg" width="1024" height="213" alt="">
</a>

现在点击它,将加载page2

答案 3 :(得分:0)

首先为您的图片设置点击事件,如下所示:

<img src="IOS_landing_V02_05.jpg" width="1024" height="213" alt="" onclick='newhtml()'>

// Function in head part
<script>
function Previewmode()
{
// load new html page
   window.open("http://newpage.html");   
}   
</script>