18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
console.log('[Web] received (from iframe (Sharedworker)):', oEvent);
}
}
/*
* Creation d'une iframe pour communiquer entre la page visitée et le Shareworker
*/
var iframe = document.createElement('iframe');
iframe.id = "GrammaFrameModule";
iframe.src = browser.extension.getURL('content_scripts/comunicate.html');
iframe.hidden = true;
iframe.onload= function() {
console.log('[Web] Init protocol de communication');
//var iframeContent = iframe.contentWindow;
var iframeContent = document.getElementById("GrammaFrameModule").contentWindow;
iframeContent.addEventListener("message", receivedMessageIframe, false);
try {
//La frame est chargé on envoie l'initialisation du Sharedworker
console.log('[Web] Initialise the worker :s');
console.log('[Web] Domaine ext: '+browser.extension.getURL(''));
iframeContent.postMessage({sPath:browser.extension.getURL(''), sPage:location.origin.trim("/")}, browser.extension.getURL('') );
//Un petit test pour débogage ;)
console.log('[Web] Test the worker :s');
iframeContent.postMessage(["parse", {sText: "Vas... J’en aie mare...", sCountry: "FR", bDebug: false, bContext: false}], browser.extension.getURL(''));
}
catch (e) {
console.error(e);
}
}
document.body.appendChild(iframe);
|
>
|
|
|
|
|
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
console.log('[Web] received (from iframe (Sharedworker)):', oEvent);
}
}
/*
* Creation d'une iframe pour communiquer entre la page visitée et le Shareworker
*/
let sFrameID = browser.extension.getURL("").split('/').pop();
var iframe = document.createElement('iframe');
iframe.id = sFrameID;
iframe.src = browser.extension.getURL('content_scripts/comunicate.html');
iframe.hidden = true;
iframe.onload= function() {
console.log('[Web] Init protocol de communication');
//var iframeContent = iframe.contentWindow;
var iframeContent = document.getElementById(sFrameID).contentWindow;
iframeContent.addEventListener("message", receivedMessageIframe, false);
try {
//La frame est chargé on envoie l'initialisation du Sharedworker
console.log('[Web] Initialise the worker :s');
console.log('[Web] Domaine ext: '+browser.extension.getURL(""));
iframeContent.postMessage({sPath:browser.extension.getURL(""), sPage:location.origin.trim("/")}, browser.extension.getURL("") );
//Un petit test pour débogage ;)
console.log('[Web] Test the worker :s');
iframeContent.postMessage(["parse", {sText: "Vas... J’en aie mare...", sCountry: "FR", bDebug: false, bContext: false}], browser.extension.getURL(""));
}
catch (e) {
console.error(e);
}
}
document.body.appendChild(iframe);
|