0
브라우저 시작시 백그라운드 페이지에서 로그인 코드를 한 번만 실행하려고합니다. 하지만 bgpage의 글로벌 코드는 매번 클릭 할 때마다 실행됩니다. 또한 다른 범위에서 실행됩니다. 이 문제를 해결할 수 있습니까?백그라운드 코드가 팝업으로 실행됩니다.
// background.js
var someCustomType = new SomeCustomType();
function SomeCustomType() {
this.firstProperty;
}
function thisShouldBeCalledOnce() {
someCustomType.firstProperty = 'defined';
alert('someCustomType.firstProperty=' + someCustomType.firstProperty);
console.log('thisShouldBeCalledOnce');
}
if (true) {
// Alwase 'undefined'
alert('someCustomType.firstProperty=' + someCustomType.firstProperty);
thisShouldBeCalledOnce();
}
참, 내 버그를 발견했습니다.''는'popup.html'에있었습니다. – Vasya