1

I'm writing an editor, and I want to open a 'preview' view of the edited text. I want this to have its own css and javascript, independent of the main editor window. However, opening it in new tab is awkward (user has to compare the preview in one tab with the source in another); there isn't space for it to go into an iframe in the main window; opening the preview in a new window also has the effect (in some browsers, with some settings) of opening a blank tab as well as the window, with the blank tab taking the focus from the main window. So none of those are satisfactory.

What would work really nicely would be something like a jquery basic dialog, that constrains the preview to appear within the main window frame (so it doesn't get lost somewhere in the desktop), and also allows you to edit the text in the main window (ie, not modal). But -- I don't see anyway of loading a whole html page with head, its own css and js files, etc, into the jquery basic dialog. Indeed, I suspect this is impossible because the dialog is seen by jquery as a part of the main page, and so cannot have a separate etc.

So, any ideas as to how this can be done? I would settle for just the ability to open a new window WITHOUT opening a tab as well -- but don't see how to do this from javascript.

And -- the content of the preview is dynamically generated, and cannot come from static files.

PS: I think this can be done through embedding an iFrame in the basic dialogue. Well, ok then -- special prizes if anyone has an alternative.

Peter

peter
  • 195
  • 1
  • 1
  • 10

1 Answers1

1

Use an iframe. You need to open a new context window because you'll likely have another set of sylesheets and other context sensitive global-ish definitions.

Halcyon
  • 57,230
  • 10
  • 89
  • 128
  • Well, yep. Concluded that. And now I have a new problem. srcdoc does *not* work in Firefox. The obvious thing would be to populate the iframe with srcdoc, dynamically generated, and then stick the iframe in the dialog. Works beautifully in chrome safari. Firefox, nope – peter Jul 25 '13 at 23:59
  • Try this http://stackoverflow.com/questions/13214419/alternatives-to-iframe-srcdoc – Halcyon Jul 26 '13 at 11:43