"document is undefined": document.getElementById("map_canvas")

41 views
Skip to first unread message

ifido...@gmail.com

unread,
Sep 1, 2008, 7:31:05 PM9/1/08
to ubiquity-firefox
Hi everyone,

Recently I have started to make something with Ubiquity. I have a line
like this:

- :: document.getElementById("map_canvas")

which is suppose to get the this:

- :: <div id="map_canvas"></div>

inside of the preview box. But, an error pops up saying: "An exception
occurred while loading code.ReferenceError: document is not defined."
Any ideas to how to fix this or a workaround?

Thanks,

Mike

Morgan Allen

unread,
Sep 1, 2008, 7:34:12 PM9/1/08
to ubiquity...@googlegroups.com
Try Application.activeWindow.activeTab.document instead.
--
http://morglog.alleycatracing.com
Lets make up more accronyms!

http://www.alleycatracing.com
LTABOTIIOFR! ROFL! ROFL! ROFL!
Upcoming alley cats, reviews, touring logs, and a general congregation of bike nerdity.

Blair McBride

unread,
Sep 1, 2008, 7:41:45 PM9/1/08
to ubiquity...@googlegroups.com
If that code is executed from the command (rather than from within the
preview HTML) it won't work. Commands are run within a sandbox which has
no document. I'd suggest using jQuery to deal with the DOM - in your
example, you'd use:

jQuery("#map_canvas", previewBlock).get(0)

to get the DOM node. Where previewBlock is the name of the first
argument in the preview() function in your command.

An alternative way would be to insert the Javascript into the preview
HTML, so it runs within that context. That may be a bit messy however,
as currently there's no easy way to separate the preview HTML into its
own file.

Hope that helps.


- Blair

Blair McBride

unread,
Sep 1, 2008, 7:44:23 PM9/1/08
to ubiquity...@googlegroups.com
> Try Application.activeWindow.activeTab.document instead.

That will get the document for the active tab - but what is wanted is
the document for the preview.

- Blair

Morgan Allen wrote:
> Try Application.activeWindow.activeTab.document instead.
>
>
> On Tue, Sep 2, 2008 at 1:31 AM, ifido...@gmail.com

> <mailto:ifido...@gmail.com> <ifido...@gmail.com

ifido...@gmail.com

unread,
Sep 1, 2008, 9:13:17 PM9/1/08
to ubiquity-firefox
Ah, thank you for helping me. I have tried both of the methods you
guys suggested. The one with the tab is not what I had in mind, and
this one:

- :: jQuery("#map_canvas", previewBlock).get(0)

returns "undefined" for some reason.

Thanks,

Mike

On Sep 1, 4:44 pm, Blair McBride <unfocu...@gmail.com> wrote:
>  > Try Application.activeWindow.activeTab.document instead.
>
> That will get the document for the active tab - but what is wanted is
> the document for the preview.
>
> - Blair
>
> Morgan Allen wrote:
> > Try Application.activeWindow.activeTab.document instead.
>
> > On Tue, Sep 2, 2008 at 1:31 AM, ifidownf...@gmail.com
> > <mailto:ifidownf...@gmail.com> <ifidownf...@gmail.com
Reply all
Reply to author
Forward
0 new messages