如何在我的網頁上的所有鏈接上禁用網站預覽功能?這是當用戶將鼠標移動到頁面中的任何鏈接上時,我想顯示一個簡單的彈出窗口,它將鏈接加載到頁面中。我嘗試在Google和stackoverflow的幫助下自己做。但是,結果得到了這樣的事情 -如何啓用並修復鏈接懸停的預覽頁面?
(實際的頁面LINK渲染)
我應該如何解決這個問題?我想讓它與Google即時預覽類似。
這裏是我的代碼 - (網站鏈接是從Web服務獲取)
HTML文件
<div class="text-result" *ngIf="Display('all')">
<div *ngFor="let item of items$|async" class="result">
<div class="frame">
<script>
$(".head-link").mouseover(function() {
$(this).children(".tooltip").show();
}).mouseout(function() {
$(this).children(".tooltip").hide();
});
</script>
<div class="title">
<a href="{{item.link}}" class="head-link">{{item.title}}
<iframe id="tooltip" src="{{item.link}}"></iframe>
</a>
</div>
</div>
<div class="link">
<p>{{item.link}}</p>
</div>
<div>
{{item.pubDate|date:'fullDate'}}
</div>
</div>
</div>
css文件
.head-link {
color: #069;
cursor: pointer;
}
.tooltip {
display: none;
position: absolute;
border: 1px solid #000;
width: 400px;
height: 400px;
}
很難說沒有看到代碼正常工作。你能爲我們設置一個jsfiddle嗎?此外,出於安全原因,許多站點不允許在iframe中查看,所以也許這是您的麻煩。你的Chrome控制檯有任何錯誤? – Adam
Chrome控制檯沒有錯誤。有很多代碼。所以,我不能把jsfiddle。這些鏈接是從Web服務中獲取的。 –
JS小提琴應該只包含你需要的複製問題,你不需要把所有的代碼放在那裏,只需要複製問題。 – Adam