asp JS 榧犳爣鐐瑰嚮澶嶅埗鍐呭
鍦ˋSP涓娇鐢↗avaScript鏉ュ疄鐜伴紶鏍囩偣鍑诲悗澶嶅埗鍐呭鐨勫姛鑳藉彲浠ラ氳繃浠ヤ笅浠g爜瀹炵幇锛

<%@ Language=VBScript %>

	ASP JavaScript 榧犳爣鐐瑰嚮澶嶅埗鍐呭



<% ' ASP閮ㄥ垎鐢熸垚闇瑕佸鍒剁殑鍐呭 %>
    
    
杩欓噷鏄渶瑕佸鍒剁殑鍐呭銆


浠ヤ笂浠g爜浼氬湪缃戦〉涓樉绀轰竴娈垫枃瀛楋紙鈥滆繖閲屾槸闇瑕佸鍒剁殑鍐呭鈥濓級锛屽綋榧犳爣鐐瑰嚮璇ユ枃瀛楁椂锛屼細璋冪敤copyToClipboard()鍑芥暟杩涜澶嶅埗鎿嶄綔銆






asp JS 榧犳爣鐐瑰嚮澶嶅埗鍙橀噺鍐呭
鍦ˋSP涓娇鐢↗avaScript鏉ュ疄鐜伴紶鏍囩偣鍑诲悗澶嶅埗鍙橀噺鐨勫唴瀹瑰彲浠ラ氳繃浠ヤ笅浠g爜瀹炵幇锛

<%@ Language=VBScript %>

	Copy Variable Content



   

杩欐浠g爜浼氬垱寤轰竴涓寜閽紝褰撶偣鍑昏鎸夐挳鏃讹紝浼氳皟鐢╟opyVariableContent()鍑芥暟銆傝鍑芥暟棣栧厛鑾峰彇闇瑕佸鍒剁殑鍙橀噺锛堝皢<%= YourVariableName %>鏇挎崲涓哄疄闄呯殑鍙橀噺鍚嶇О鎴栧硷級锛岀劧鍚庡垽鏂祻瑙堝櫒鏄惁鏀寔Clipboard API銆傚鏋滄敮鎸侊紝鍒欑洿鎺ュ啓鍏ュ壀璐存澘锛涘鏋滀笉鏀寔锛屽垯灏嗗彉閲忕殑鍊艰缃埌涓涓殣钘忚緭鍏ユ涓紝骞堕変腑鏂囨湰锛屾渶鍚庢墽琛屽懡浠よ繘琛屽鍒舵搷浣溿傛棤璁轰綍绉嶆儏鍐碉紝閮戒細鏄剧ず鎻愮ず淇℃伅琛ㄦ槑澶嶅埗鎴愬姛銆




濡傛灉鏈夊琛屾暟鎹唴瀹癸紝鍙敤浠ヤ笅浠g爜銆

<%@ Language=VBScript %>
<!DOCTYPE html>
<html>
<head>
    <title>ASP姣忚榧犳爣鐐瑰嚮澶嶅埗</title>
    <script type="text/javascript">
        function copyToClipboard(elementId) {
            var element = document.getElementById(elementId);
            
            // 鍒涘缓涓存椂鏂囨湰杈撳叆鍏冪礌
            var tempInput = document.createElement("input");
            tempInput.type = "text";
            tempInput.value = element.innerText;
            document.body.appendChild(tempInput);
            
            // 閫変腑骞跺鍒舵枃鏈
            tempInput.select();
            document.execCommand('copy');
            
            // 绉婚櫎涓存椂鏂囨湰杈撳叆鍏冪礌
            document.body.removeChild(tempInput);
            
            alert("宸叉垚鍔熷鍒跺埌鍓创鏉匡紒");
        }
    </script>
</head>
<body>
    <% ' ASP鐢熸垚琛ㄦ牸鏁版嵁 %>
    <% For i = 1 To 5 %>
        <div onclick="copyToClipboard('row<%=i%>')" id="row<%=i%>" style="cursor: pointer;">杩欐槸绗 <%=i%> 琛岀殑鍐呭</div><br/>
    <% Next %>
    
    <!-- 鍏朵粬椤甸潰鍐呭 -->
</body>
</html>


浠ヤ笂灏辨槸JS 榧犳爣鐐瑰嚮澶嶅埗鍙橀噺鍐呭鐨勮缁嗗唴瀹癸紝鏇村淇℃伅璇峰叧娉∣D浜戝叾瀹冪浉鍏虫枃绔狅紒



鏈枃URL锛http://www.odweb.cn/news_show.html?id=291