Guy Guy - 1 month ago 7
Javascript Question

jquery selector not working in Gmail

I'm using Jquery to modify the Google navigation toolbar (the black one).

This selector works on google.com and some other google sites like Google Plus (plus.google.com):

$("#gbzc").find("li.gbt")


(this selects the li items in the toolbar)

But for some reason, inside gmail, this selector doesn't work. The structure of the page seems exactly the same on gmail.com and in the other google sites, but this selector doesn't return anything when run in gmail.

Any ideas?

Answer

The contents(including the toolbar) of Gmail unlike other google-pages are loaded within an iframe.

So when you use this code from the top-document you must pass the iframe-document as context(2nd argument for $() )

Comments