2017-05-31 115 views

回答

2

您可以根據您的文字在JavaScript庫html2canvas上飛行刪除圖像。例如,如果你想與ID docs成圖像變換格,你的代碼將

$(document).ready(function(){html2canvas($('#docs'), { 
 
    onrendered: function(canvas) { 
 
    $('#docs').html(canvas); 
 
    } 
 
});});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script> 
 
<div id="docs">This script allows you to take "screenshots" of webpages or parts of it, directly on the users browser. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.</div>

附:但用戶仍然能夠看到文本,如果他將檢查頁面的HTML

6

這不是一個真正的答案你的問題,但這裏更好。

只需在文字中加上一個空格,即不應該搜索並且隱藏該空白。 例如:

<p>"This is a te<span class="foo"> </span>st."</p> 

和CSS:

.foo{ 
    font-size:0; 
} 

https://jsfiddle.net/y8g10jsr/

嘗試使用CTRL + F搜索 「測試」

1

我只是嘗試這樣做的解決方法,它似乎呈現文本不可測量。

.overlook::after { 
 
    content: attr(data-text); 
 
}
<p class="overlook" data-text="Ctrl+F will not find this">

測試在Chrome,Firefox和IE。

編輯:

哦,我還沒有看到這個問題下面的評論 - 請了投票original如果你發現這很有用。

相關問題