0
我正在處理一些需要複製網頁的內容,當我複製該網頁時,我將能夠將該網頁粘貼到電子郵件中並可以發送給某人。下面的代碼只適用於複製文本或html標籤,但我需要按照原樣複製整個頁面。如果有什麼方法讓我知道。如何使用javascript/jquery將網頁複製並粘貼到電子郵件中
<p id="p1">P1: I am paragraph 1</p>
<p id="p2">P2: I am a second paragraph</p>
<button onclick="copyToClipboard('p1')">Copy P1</button>
<button onclick="copyToClipboard('p2')">Copy P2</button>
function copyToClipboard(elementId) {
// Create a "hidden" input
var aux = document.createElement("input");
// Assign it the value of the specified element
aux.setAttribute("value", document.getElementById(elementId).innerHTML);
// Append it to the body
document.body.appendChild(aux);
// Highlight its content
aux.select();
// Copy the highlighted text
document.execCommand("copy");
// Remove it from the body
document.body.removeChild(aux);
}
你不能。我的意思是你可以但不要。您可以獲取網站的整個BODY,但將其粘貼到電子郵件後,這些HTML無效HTML電子郵件,並且在郵件客戶端中永遠不會看起來不錯。我的意思是......你能解釋你的問題嗎?你怎麼了?你想要做什麼? –
你想達到什麼目的?將頁面的文本粘貼到電子郵件中?將結構(= html)粘貼到電子郵件?或者將包括樣式和圖像在內的整個事件粘貼到電子郵件中? – Woncker
是的,我想複製整個網頁,包括CSS和圖像。目前我已經使用內聯CSS來訪問頁面。這裏是網頁http://112.196.20.243:8194/wpb_appointments/raman-at-1111-am-11/ –