1

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

Adeel Aslam
  • 1,285
  • 10
  • 36
  • 69

2 Answers2

8

Something like this:

<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>
jerjer
  • 8,694
  • 30
  • 36
0

If you mean you want to open a new page on mouse over, then:


//add onmouseover to your hyperlink
<a href="#" onMouseOver="open_new_window(url);">Open Hover Window
//then js
function open_new_window(url) {
  window.open(url,"some_name","width=300,height=200,left=10,top=10");
}

Did you mean something like that

Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162