0

Well it's pretty difficult to explain my problem.

I'm currently developing a toolbar for google chrome (extension) materialized by an iframe. This iframe is as you know a HTML file, but self hosted (I mean it's a local file). Basically this file construct a basic toolbar, so what i need is to load this file, and modify it by adding some components like buttons,... Then when i've made the change i need to save this file to then load it on a iframe. But i have a LOT of issue to do that, i can't find a solution to do that...

Hope someone can provide me some help !

Sindar
  • 10,389
  • 6
  • 32
  • 44
  • Why do you need to modify the actual html, isn't it possible to make those changes dynamically with javascript? – serg Mar 09 '11 at 16:03
  • No because when i try to modify it dynamically with javascript i have Same Origin Policy problem... That's why i need to modify the html before inserting it. Because after that i can't provide change on it. – Sindar Mar 09 '11 at 16:13
  • What about passing parameters to iframe through url and then making according changes in iframe's javascript? – serg Mar 09 '11 at 16:24
  • Yeah but, imagine that i need to create 10 buttons by passing parameter through the url... It will be discusting and unclean... – Sindar Mar 09 '11 at 16:30
  • 1
    Do you know upfront what kind of buttons will be there? Then you can just do `?show_buttons=1,3,6,10`. You can store all other permanent styling options in localStorage for example, and then read them from your iframe. There is no easy way to generate physical files from javascript, so it is pretty much a dead end. – serg Mar 09 '11 at 16:36
  • It could be a interesting idea dude ! Did you have other solution ? Like using the postMessage to communicate, or JSON Stringify. And also use the HTML5 File Writer API ? – Sindar Mar 09 '11 at 16:44
  • Not sure what `postMessage` is, and HTML5 file api is still at very early stage from what I can tell. Maybe you won't even need to pass any url parameters, just store everything in a localStorage (it would require json stringify as you can store there only strings) – serg Mar 09 '11 at 16:51

1 Answers1

1

This answer may help:

Can't write to dynamic iframe using jQuery

Community
  • 1
  • 1
Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176