I am the developer of a webapplication.
Chrome displays my Javascript-and-AJAX-generated webpages correctly, but when I try and print them (via its native function) I get a blank page.
Printing works just fine on other browsers.
I have tried and print server-side-generated pages with Chrome and they get printed fine.
What can be wrong on the webpages of my web application? I think the issue is that those pages are dynamically generated by Javascript and AJAX.
I am saying that because I have just found out that I can't even save those pages correctly with Chrome (all the dynamic HTML is not shown).
I am on Google Chrome 13.0.782.112.
How can I debug and fix this issue?
Is there any workaround?
Is anybody managing to get dynamic-generated content printed with Google Chrome?
This problem is driving me crazy!
P.S.: some of my users are reporting the same problem on Safari :-(
UPDATE: upgraded to Chrome 14.0.835.202 but the issue is still there...
I've had exactly the same problem, though not in Chrome (although I didn't actually test with Chrome). On certain browsers (and I cannot remember which ones offhand - but it was either in IE or FF), any content that is added into the DOM by JavaScript is not printed. What is actually printed is the original document that was served to the browser.
I successfully solved this using the following JavaScript function:
function docw()
{
var doct = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
document.write(doct + document.getElementsByTagName('html')[0].innerHTML);
}
This is called when JavaScript page manipulation has finished. It actually reads the entire DOM and then re-writes the whole document back into itself using document.write. This is now enabling printing for my particular project on both IE and FireFox, although I'm pretty sure one of those did already work in the first place, and the other one didn't (can't remember which from memory, and it's not a project I can pull out to test at the moment). Whether this will solve the problem in Chrome I don't know, but it's worth a try.
Edit Terribly sorry, but I'm a complete pleb. I just re-read my old comments and this solution had nothing to do with printing; it was actually to fix a problem where only the original served document would be saved when saving to file. However, that said, I still wonder if it's worth a shot.
This helped me with a related problem - how to view/save dynamically generated HTML itself. I came up with the following bookmarklet.
javascript:(function(){document.write('<pre>'+(document.getElementsByTagName('html')[0].innerHTML.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'))+'</pre>')})()
I run this and 'select all' / copy, and then (in Linux) do 'xclip -out' to direct the large amount of clipboard data to a file.
Trevor's answer totally worked for me- with jquery I simply did something like
$("html").html $("html").html()
worked perfectly
Related
I am trying to include a file (that's in html) inside of my HTML code. When i test it by opening it in my browser i can view the text fine, however when I upload it it does not appear. In chrome nothing appears and in IE it says that this content cannot be displayed.
<p><object src="resume-kylerschnaible.html"><embed src="resume-kylerschnaible.html" height="1300px"></embed></object></p>
http://jsfiddle.net/rd7yqo6m/
HTML isn't really the tool of choice for including files, there are countless security settings that are dependent upon browser and server configuration so these kind of include methods are generally seen as unreliable. I would suggest moving to php or asp.net if you need this kind of functionality. Failing that you might find that the iframe method is slightly more flexible.
<iframe src="resume-kylerschnaible.html"></iframe>
Does greasemonkey or tampermonkey have functionality that lets me edit the raw HTML response before it gets passed to the browser?
I'm trying to do this in an attempt to modify an inline script before it executes. This solution must work on both Firefox and Chrome so something like beforescriptexecute won't work because chrome doesn't support it yet.
If not, is there an extension that does provide this functionality that is available to both browsers?
Quick answer: No.
Longer answer: Tampermonkey and Greasemonkey operate on editing the page has loaded, not at any time prior to that. So, preventing a script from executing isn't going to happen. Neither of these tools can change the code before it's run, it only alters once it has run and can inject certain scripts into the page after it's loaded that affect the data displayed or the appearance. The best you could do is update or replace what's displayed based on the inline script, but it's still going to get sent initially.
I am developing a Google chrome extension. Everything works fine except that the extension causes the page to crash when viewing an XML file (such as a Site Map).
I have narrowed the issue down to using chrome.storage.local and the problem does not occur when that is taken out.
I realize this isn't a major problem as XML files are only rarely viewed in a browser by most people but, as a developer, I often view Site Maps and other XML files and it is really bugging me.
I have not been able to find any other info about this on google. Is this a bug with chrome.storage or could it be something else entirely?
Thanks,
Have submitted a bug report: https://code.google.com/p/chromium/issues/detail?id=151838&q=chrome.storage%20XML&colspec=ID%20Pri%20Mstone%20ReleaseBlock%20OS%20Area%20Feature%20Status%20Owner%20Summary
In the mean-time, I am using this code as a work around:
var isXML = new RegExp(".+\\.[Xx][Mm][Ll](\\?|$)", "i").test(window.location.href);
if (isXML == false) { RunExtension(); }
Hope this helps someone else.
I'm experiencing the strangest problem. I have a development site page that for some users is rendering incomplete in all browsers. Viewing the source shows it to be cut off at a certain point, with no closing body or html tags anywhere. Logging the response body on the server when this page is being served to them, however, shows it to be complete. At first I thought it may be a network issue, but this problem has been experienced in multiple locations located far from either other. Just as strange, if the user loads the same complete source code as a static page instead of a dynamic one, the page renders correctly every time. I'm using Rails 2.3.8 w/ Rack 1.1.3, Passenger 3.0.9, and Nginx 1.0.6 FYI. Any suggestions? Thanks.
Problem solved. There was a large JSON object assigned to a variable on the page that was used to by the autocomplete methods of various fields. After removing this on-page JSON object and loading it from another URL using the jQuery getJSON() method, the problem went away. Definitely a rare issue, but hopefully this will help someone else.
I have an ExtJS application that needs to display an html document within a panel. The application works fine in FF and chrome However, when I attempt to use this functionality inside Internet Explorer 8 a pop-up appears:
"Do you want to save this file, or find a program online to open it?
Name: getBinary Type: Unknown File Type, 688KB From:
SERVER_NAME_HERE"
I have not included the code because it's my company's property but could probably create a mock-up if it's really needed. I first wanted to see if there was any common knowledge on this type of issue that I haven't been able to find online.
Ok I figured it out and have to apologize to the good people here at stackoverflow. IE8 was not having trouble displaying a .html page. The page was actually a .xhtml file which I learned by digging deeper into the code, one of our developers just named it .html :/
So there are two different solutions to get internet explorer 8 to display a .xhtml file.
You can use the hack/fix mentioned here w3c xhtml fix
You can change the .xhtml file's extension to .html (this is more risky) but in my particular case no additional information was being lost.