2

I've created a project with the moovweb sdk and have trouble editing the content within an iframe on one of the pages. For instance, moving a div around inside the iframe doesn't seem to work with the tritium I'm writing. What can I do with tritium to make this work? The domains are different FYI.

Alex De Simone
  • 572
  • 1
  • 4
  • 8

3 Answers3

1

Unfortunately, Tritium only allows you to edit the attributes of the iframe itself, not the content within.

This is because the request for content in the iframe is made after the browser constructs the DOM of the main page. Tritium can only intercept the first request for the main page, not the second request for content from a different domain.

I know of two workarounds:

  1. Add the second website as a Moovweb project and you will be able to use Tritium to manipulate the content. Then you can point the iframe of the original page to this new content.
  2. Use JavaScript/AJAX to modify the iframe's content.

However there are implications for production domains... I'm afraid I may have rushed this answer and will update it after I do more research.

gregorygtseng
  • 851
  • 4
  • 12
  • It's worth noting that if the domains were the same then you could use Tritium. It's also worth clarifying this is an issue that is inherent in the web and not a tritium flaw. By the way, I don't think option 2 (using JavaScript to modify the frame content) will work since the same origin policy will prevent JS from effecting the iframe's DOM. – Ishan Jul 11 '13 at 05:09
1

If the iframe is on the same origin (http://m.yoursite.com) or on an origin you have in your config.json you can absolutely use tritium! However, maybe not in the way you expect!

So, the iFrame is going to make a separate request to the src attribute's location. If you ensure this request is going through the SDK (by rewriting it) like so:

$(".//iframe[@src]") {
  attribute("src") {
    rewrite("link")
  }
}

Then you can map that url and perform your regular tritium on it!

0

you need to analyses the src of iframe and need to write mapping in mappings.ts for the url in src. Include proper .ts file in pages folder and start transforming it.

anurodh sahu
  • 123
  • 1
  • 6