CONTEXT
I am creating an http://canvimation.github.com/ that uses javascript to create web pages dynamically.
The source code for my application is at https://github.com/canvimation/canvimation.github.com
The application uses Canvas to draw using vector objects the resulting drawing can then be exported as a web page. To create a web page click on the FILE icon and then 'Export Canvas to HTML'.
The exporting code opens a new window and uses document.writenl() to construct the code. The relevant function is shown at the end of the question.
All browsers I have tried produce the drawing correctly in the new window as a web page. In all browsers view source shows the expected code for the application web page.
In IE10 and Firefox it is possible to view the source of the exported code which can then be saved and the saved file used as a webpage.
For the exported web page: in Chrome 28 view source is greyed out and not available; in Safari 5 for Windows view source produces a blank window and in Opera 12 source does not do anything.
QUESTIONS
- How is it possible to save or view the source of the exported webpage in Chrome, Safari and Opera?
- Can anything be changed in my method to dynamically create a webpage that can have its source code viewed and saved?
RELEVANT CODE
function exportShapes()
{
var shapelist=[];
var nameZ=[];
for (var name in SHAPES)
{
nameZ=[];
nameZ.push(name);
nameZ.push(SHAPES[name].zIndex);
shapelist.push(nameZ);
}
shapelist.sort(compareZ);
newwindow=window.open('','export');
newwindow.document.writeln('');
newwindow.document.writeln('');
newwindow.document.writeln(SPACES.substr(0,3)+'');
newwindow.document.writeln(SPACES.substr(0,6)+'');
newwindow.document.writeln(SPACES.substr(0,6)+'');
newwindow.document.writeln(SPACES.substr(0,6)+'');
newwindow.document.writeln(SPACES.substr(0,3)+'');
newwindow.document.writeln(SPACES.substr(0,3)+'');
newwindow.document.writeln(SPACES.substr(0,6)+'');
newwindow.document.writeln(SPACES.substr(0,3)+'');
newwindow.document.writeln('');
newwindow.document.close();
}
No comments:
Post a Comment