카테고리 없음
화면 소스 복사 jquery
[czar]
2010. 12. 23. 10:13
<html>
<head>
<script src="jquery-1.3.2.min.js"></script>
<script src="jquery.includeMany.js"></script>
<script src="jquery.copyable.js"></script>
</head>
<body>
<script>
$(document).ready(function(){
$("#buttonToClickOn, #divToClickOn").copyable(function(e, clip) {
clip.setText($("#elementWithText").html());
});
});
</script>
<p style="color:red">Please note that zeroclipboard does not work on when viewing this file except when served by a webserver.</p>
<div id="elementWithText">This text will be copied to the clipboard</div><br/>
<form>
<div id="divToClickOn" style="background-color:grey;width:200px">Click Me</div><br/>
<input type="button" id="buttonToClickOn" value="Click Me"/><br/><br/>
Clipboard test area:<br/>
<textarea rows="10" cols="50"></textarea>
</form>
</body>
</html>
<head>
<script src="jquery-1.3.2.min.js"></script>
<script src="jquery.includeMany.js"></script>
<script src="jquery.copyable.js"></script>
</head>
<body>
<script>
$(document).ready(function(){
$("#buttonToClickOn, #divToClickOn").copyable(function(e, clip) {
clip.setText($("#elementWithText").html());
});
});
</script>
<p style="color:red">Please note that zeroclipboard does not work on when viewing this file except when served by a webserver.</p>
<div id="elementWithText">This text will be copied to the clipboard</div><br/>
<form>
<div id="divToClickOn" style="background-color:grey;width:200px">Click Me</div><br/>
<input type="button" id="buttonToClickOn" value="Click Me"/><br/><br/>
Clipboard test area:<br/>
<textarea rows="10" cols="50"></textarea>
</form>
</body>
</html>
테스트로 팝업에서
var html = $("#contents", opener.document).html();
src 랑 href 링크 경로에 도메인 붙이기
html = html.replace(/src=\"/gi,'src="http://domain.com');
html = html.replace(/href=\"/gi,'href="http://www.domain.com');
clip.setText(html); alert('소스코드가 정상적으로 복사 되었습니다.');