在div标签内打开URL [英] Open URL inside a div tag

查看:141
本文介绍了在div标签内打开URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个表格单元格中有一个div标签,在另一个单元格中有一个超链接标签,在上面我想在div标签中的超链接上打开一个特定的onmouseover URL.URL是我的pdf文件.请告诉我如何我使用这种Java语言或其他任何方法

I have a div tag inside a table cell and and a hyperlink tag in another cell and on i want open a specific url onmouseover on hyperlink inside the div tag.the url is to my pdf file.Please anyone tell me how can i do this thorugh Javascript or anyother method

推荐答案

类似以下内容:

<table>
<tr>
<td>
    <a href="/pdfs/test1.pdf" onmouseover="previewUrl(this.href,'div1')">google</a>
</td>
<td>
    <div id="div1" style="width:400px;height:200px;border:1px solid #ddd;"></div>
</td>
</tr>
</table>

<script>
    function previewUrl(url,target){
        //use timeout coz mousehover fires several times
        clearTimeout(window.ht);
        window.ht = setTimeout(function(){
            var div = document.getElementById(target);
            div.innerHTML = '<iframe style="width:100%;height:100%;" frameborder="0" src="' + url + '" />';
        },20);      
    }   
</script>

这篇关于在div标签内打开URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆