I am using Firefox addon-sdk to create add-ons for the Firefox browser.
I need to copy text from a text element to the clipboard in the popup.html file. I do not want to use flash to copy text to the clipboard.
popup.html
<html>
<head>
<meta charset="utf-8"/>
<script src="jquery.min.js"></script>
<script type="text/javascript" src="const.js"></script>
<script type="text/javascript" src="popup.js"></script>
<script>
</script>
</head>
<body style="font-family:Tahoma, Geneva, sans-serif;line-height:30px;width:250px;">
<form >
element Id : <input type="button" onclick="copy($('#idElem').val())" class="btn" value="copy"/>
<input type="text" id="idElem" value=""/><br/>
element class name : <input type="button" class="btn" onclick="copy($('#classNameElem').val())" value="copy"/>
<input type="text" id="classNameElem" value=""/><br/>
element xpath : <input type="button" onclick="copy($('#xpathElem').val())" class="btn" value="copy"/>
<input type="text" id="xpathElem" value=""/><br/>
</form>
</body>
</html>
And the popup.js file:
$(document).ready(function () {
addon.port.on("vars", function(vars) {
if (vars){
$("#idElem").val(vars[0]);
$("#classNameElem").val(vars[1]);
$("#xpathElem").val(vars[2]);
}
});
});
How can i do this?
source
share