, 하나는 윈도우 개체를 반복 할 수 -반복 정상 JS에서
<html><head><script>
function one(){
}
function two(){
for (var i in window) {
if (i=='one') {
alert(i);//.......................shows 'one'
}
}
}
two();
</script></head></html>
그러나 그리스 몽키의 '창'보유하지 않는 기능, 당신은 GM 스크립트에 정의에도 기능 :
// ==UserScript==
// @name Page 3
// @namespace http://xxxxxxxxxxxxxxxx
// @include http://xxxxxxxxx.net/3.html
// ==/UserScript==
//
function one(){
}
function two(){
for (var i in window) {
if (i=='one') {
alert(i);//.........shows nothing, only iterates native window props
}
}
}
two();
예, unsafeWindow에있는 함수가 아니라 내 자신의 함수를 반복하고 싶습니다.
window.one=function one(){
}
function two(){
for (var i in window) {
if (i=='one') {
alert(i);//...........ta-da! 'one'
}
}
}
two();
그래서이 세계 공간의 이름은 무엇이며, 어떻게 그것을 반복 할이 이상에 대한 의도와 최상의 방법은 무엇인가 : 나는 싶지 않아 다음 작품이 있습니다? 고맙습니다.
업데이트 : -
// ==UserScript==
// @name Page 3
// @namespace http://xxxxxxx.net
// @include http://xxxx.com/*
// ==/UserScript==
function do_fixes(){
var s='';
for (var i in this) {
if (i=='do_fixes') {
alert('yes');
}
}
if (window!=this) {
alert('window!=this');
}
}
do_fixes();
alert('this script ran!');
답장을 보내 주셔서 감사합니다.하지만 '이'에는 기능이 없습니다. 지금 내 소식을 업데이트했습니다. –