1
Google 크롬 확장 프로그램 (https://chrome.google.com/webstore/detail/fhmcfamnddgoloojehbeokifhaiiebfm)을 작성했으며, 내 Linux에서 확장 기능을 사용할 수 있습니다. 데스크톱 (내 데비안 불안정에서 Chromium 13.0.782.107 ~ r94237-1을 실행 중임)간혹 tabs.getSelected 콜백이 실행되지 않습니다.
chrome.tabs.getSelected
에 전달하는 콜백이 내 랩톱에서 실행되지 않는 것 같습니다. 이 팝업 페이지는 디버거에서 열립니다. (하지만 내 바탕 화면에서 완벽하게 작동합니다.) 무슨 일이 벌어지고 있는지 알겠습니까?
<html>
<head>
<script type="text/javascript">
function goTo(url){
if (url.search("://") == -1 &&
url.search("@") != -1 &&
url.search("mailto:") == -1) url = "mailto:"+url;
else if (url.search("://") == -1) url = "http://" + url;
url = url.replace(/\s/g,"");
console.log(url);
chrome.tabs.getSelected(null,function(tab){
chrome.tabs.update(tab.id,{"url":url});
});
window.close();
}
function pasteHandler(e) {
var t = e.target.type;
if (t == "textarea" || t == "text" || t == "password"
|| e.target.isContentEditable) {
return;
}
var url = e.clipboardData.getData("text/plain").replace(/^\s+|\s+$/g, '');
goTo(url)
}
function textBoxEnterPressed(e){
if(e.keyCode == 13){
goTo(document.getElementById('edit').value);
return false;
}
return true;
}
</script>
</head>
<body onpaste="pasteHandler(event)">
<table border="0" cellpadding="0" cellspacing="0" style="float:left">
<tr><td>
Paste in the text box to edit the URL first,
or paste outside the box to go straight there.
</td></tr>
<tr><td>
<input type="text" name="edit" id="edit" size="100"
onkeypress="return textBoxEnterPressed(event)"/>
</td></tr>
</table>
</body>
</html>
해결했습니다. 콜백과 window.close 사이에는 경쟁 조건이 있었고 내 바탕 화면과 디버거는 더 나은 타이밍을 가졌습니다. –