0

I would like to interact with the DOM immediately when the element becomes available. I can do this with a setInterval, but it won't work with Crossrider because the js that can interact with the DOM is only loaded once the DOM is ready. Any way to get aroind this?

Thanks

Jacques Blom
  • 1,794
  • 5
  • 24
  • 42
  • Are you trying to interact with the DOM from a browser plugin? Or from javascript embedded in the page? – jfriend00 Nov 14 '12 at 07:01
  • I am trying to interact with the DOM using jacascript from a browser plugin I am writng. – Jacques Blom Nov 14 '12 at 07:23
  • Don't know Crossrider, but can't you load it earlier? In the head for example. – HBP Nov 14 '12 at 07:01
  • Crossrider apparently only allows you to inject JavaScript into a page when the DOMReady event has fired. I want to inject JavaScript before the dom has finished loading. – Jacques Blom Nov 14 '12 at 10:54

2 Answers2

2

The current API doesn't officially support this feature at this time.

However, you're welcome to try our new appAPI.dom methods which work in Chrome and Firefox but are currently undocumented until they are officially released. The new methods are pretty self-explanatory, so I've listed them here with a brief description:

  • appAPI.dom.onDocumentStart.addJS(String jsCode, [Array siteList])
    This method adds the specified jsCode when the document starts to load. Optionally specify an array of strings/regex expressions (see http://docs.crossrider.com/#!/api/appAPI-method-isMatchPages for examples) specifying which URLs to add the code to.
  • appAPI.dom.onDocumentStart.addCSS(String cssRules, [Array siteList])
    This method adds the specified cssRules when the document starts to load. Optionally specify an array of strings/regex expressions (see http://docs.crossrider.com/#!/api/appAPI-method-isMatchPages for examples) specifying which URLs to add the CSS to.
nickb
  • 59,313
  • 13
  • 108
  • 143
Shlomo
  • 3,763
  • 11
  • 16
  • Thanks! I'll try this out for Firefox. Do you perhaps know when it might become available for IE and Safari? – Jacques Blom Nov 17 '12 at 09:08
  • @JacquesBlom: It's on our roadmap, but we don't as of yet have a date for their release as there are some major projects that must be completed first. – Shlomo Nov 19 '12 at 14:13
0

you might want to check out the appAPI.dom.onDocumentStart object because it doesn't seem to be defined even when called after appAPI.ready(). This is the error I'm getting:

Uncaught TypeError: Cannot call method 'addCSS' of undefined

Thanks! Keep up the good work!

Brian Mayer
  • 989
  • 3
  • 13
  • 23