XUL iframe firefox addon, how to change the src within the iframe?

132 views Asked by At

I am developing a firefox addon,

in my settings page dialog.xul i have an iframe where i load different settings pages page1.xul page2.xul page3.xul

Iframe :

<vbox flex="1">
  <iframe
      id="iframe"
      src="chrome://xxx/content/page1.xul"
      flex="1"></iframe>
</vbox>

Within the iframe i need to navigate from page2.xul to page3.xul with the code in page2.xul

My code (page2.xul) :

gBrowser.loadURI("chrome://xxx/content/page3.xul");

Also tried

 document.getElementById("iframe").setAttribute("src", "chrome://xxx/content/page3.xul");

but it's not working i know iframe container is not accessible from the iframe but how can i do that redirection ?

2

There are 2 answers

4
Noitidart On BEST ANSWER

With iframe in XUL you must create it with the HTML namespace otherwise things like load events don't work right, see this topic: http://forums.mozillazine.org/viewtopic.php?f=19&t=2809781&hilit=+iframe

Once you do that, changing src etc should work as expected.

3
intika On

Solution :

I managed to handle the code in the main XUL

Apparently XUL does not support the structure

[XUL1 >> iframe(XUL2 : change something in XUL1)]

This structure is not supported in classic HTML + Javascript for security reason and it's also the case in XUL