If you use an iframe and that the iframe is only intended to store the actual source of the page that is being edited, then you will need variables on the parent frame that contain the actual source. I would recommend saving it separately, and then using the following to execute the switches:
var actualSource = content.document.body.innerHTML; // just something to initialize it // You should probably keep it in a global object instead of as a var $('#Visualize').click(function() { actualSource = content.document.body.innerText; content.document.body.innerHTML = ""; content.document.body.innerHTML= actualSource; });
I would suggest that you have methods that capture the source, but I would suggest that you want to capture the actual source as it is at that moment. I'm not sure what you are doing with the actual part of the editing (is this an editable div, is it a text area?), But in order to run the show, you just need to switch to innerHTML and innerText between the two settings. The actual catch will control the actual controls affected by this change.
source share