【问题标题】:Can an image map be linked to open the browse file controller?可以链接图像地图以打开浏览文件控制器吗?
【发布时间】:2009-12-09 16:00:24
【问题描述】:

我希望用户能够单击我的应用程序选项卡 1 上的图像,这将打开文件浏览器以上传照片。这可能吗??

【问题讨论】:

    标签: javascript button upload hyperlink imagemap


    【解决方案1】:

    是的。

    <img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap" />
    
    <map name="planetmap">
        <area shape="rect" coords="0,0,82,126" href="javascript: document.getElementById('files').click()" alt="Sun" />
        <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury" />
        <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus" />
    </map>
    
    <form>
        <input type="file" id="files">
    </form>
    

    当您单击地图的“太阳”区域时,这将加载文件浏览对话框。

    或者,参考您的问题主体(没有图像映射)

    <script type="text/javascript" language="javascript">
        function showFileBrowser()
        {
            //maybe do something here
            var fb = document.getElementById('files');
            fb.click();
        }
    </script>
    ...
    <img src="src.ext" alt="a picture" onclick="showFileBrowser()" />
    ...
    <form action="something" method="post">
        <input type="file" id="files" />
    </form>
    

    【讨论】:

      猜你喜欢
      • 2011-01-06
      • 2011-08-18
      • 2022-08-17
      • 1970-01-01
      • 1970-01-01
      • 2014-03-08
      • 1970-01-01
      相关资源
      最近更新 更多