完全不用加事件啊,直接加个target就成了
比如document.writeln("<a target=\"_blank\" href=\"photo/photo"+photoIndex+".jpg\"><img src=\"sphoto/sphoto"+photoIndex+".jpg\" /></a>");

解决方案 »

  1.   

    我所说的打开一个新页面并打开相应的大图片的意思是:
    打开大图片的页面还有其他的东西,我现在要提取相应的photoIndex值,传到另外一个页面,方便控制图片的显示
      

  2.   

    我所说的打开一个新页面并打开相应的大图片的意思是:
    打开大图片的页面还有其他的东西,我现在要提取相应的photoIndex值,传到另外一个页面,方便控制图片的显示
    谢谢
      

  3.   

    //这样写没问题呀,你应该在你展示大图的页面(photo.asp)中获取'pp'参数中的图片地址,将其显示就行了。
    document.writeln('<a href="photo.asp?pp=photo/photo'+photoIndex+'.jpg" target="blank"><img src="sphoto/sphoto'+photoIndex+'.jpg" /></a>');
      

  4.   

    谢谢,问题是我用HTML静态页面,而不是动态页面
      

  5.   

    大概这样吧
    document.writeln("<a href=\"javascript:viewPic('photo/photo/"+photoIndex+"')\"><img src=\"sphoto/sphoto"+photoIndex+".jpg\" /></a>");
    <script language="javascript">
    function viewPic(name){
    alert('MaxPic:'+name+'.jpg');
    }
    pageIndex=1;
    switch(pageIndex)
    {
        case 1:
        {
            photoIndex=5;
            for(var i=0; i<4; i++)
            {
                document.writeln("<a href=\"javascript:viewPic('photo/photo/"+photoIndex+"')\"><img src=\"sphoto/sphoto"+photoIndex+".jpg\" /></a>");
                photoIndex+=1
            }
            break;
        }
        default:
        {
            photoIndex=(pageIndex-1)*pageSize+5;
            for(var i=0; i<4; i++)
            {
                document.writeln("<a href=\"photo/photo"+photoIndex+".jpg\"><img src=\"sphoto/sphoto"+photoIndex+".jpg\" /></a>");
                photoIndex+=1
            }
        }
    }
    </script>
      

  6.   

    楼上的大侠,你写的方法FF能够通过,但是IE却没有alert弹出,请问这是怎么回事呀?
    谢谢~~~~~~~~~~~~~~~·
      

  7.   

    var str =   'a href="photo/photo"+photoIndex+".jpg"><img src="sphoto/sphoto"+photoIndex+".jpg" /></a>';
    document.writeln(str);
      

  8.   


    <!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=gb2312" />
    <title>无标题文档</title>
    </head><body>
    <script language="javascript">
    switch(pageIndex)
    {
        case 1:
        {
            photoIndex=5;
            for(var i=0; i<4; i++)
            {
                document.writeln("<a href=\"photo/photo"+photoIndex+".jpg\" onclick=\"showB('sphoto"+photoIndex+".jpg')\"><img src=\"sphoto/sphoto"+photoIndex+".jpg\" /></a>");
                photoIndex+=1
            }
            break;
        }
        default:
        {
            photoIndex=(pageIndex-1)*pageSize+5;
            for(var i=0; i<4; i++)
            {
                document.writeln("<a href=\"photo/photo"+photoIndex+".jpg\" onclick=\"showB('sphoto"+photoIndex+".jpg')\"><img src=\"sphoto/sphoto"+photoIndex+".jpg\" /></a>");
                photoIndex+=1
            }
        }
    }function showB(picName)
    {
    alert(picName);
    }
    </script>
    </body>
    </html>