Miyako Posted March 11, 2010 Report Share Posted March 11, 2010 I'm trying to make a script that copies the content from a div to a new popup.For example: <html><head><title>Test</title</head><body><div id="test"><p>Hello</p></div></body></html> And this is the code I have atm: function printTable(table) { printPop = window.open('lol.php','Printversie','scrollbars=yes'); if (window.focus) printPop.focus(); code = document.getElementById(table).innerHTML; printPop2 = printPop.document; $(printPop2).ready(function(){ $(printPop2).$("#printContent").append(code); });} So I want that the popup (lol.php) will display something like this: <html><head><title>Print</title></head><body><p>Hello</p></body></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted March 11, 2010 Report Share Posted March 11, 2010 So what happens when you run the code? Do you get errors? Have you checked for errors? You're trying to add the content to an element with a certain ID, but I don't see an element with that ID on the other page. Link to comment Share on other sites More sharing options...
Miyako Posted March 11, 2010 Author Report Share Posted March 11, 2010 When I run it it won't give an error, it will just create an empty popup.This is the content of lol.php (the popup with the ID): <html><head><title>Print page</title></head><body><div id="printContent"></div></body></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted March 11, 2010 Report Share Posted March 11, 2010 Add an alert inside the jQuery function to make sure that code is running, and alert the code variable to make sure it contains the correct data. Link to comment Share on other sites More sharing options...
Miyako Posted March 11, 2010 Author Report Share Posted March 11, 2010 Both alerts worked after I "cleaned" the code a bit. function printTable(div) { code = document.getElementById(div).innerHTML; printpop = window.open('lol.php','Printversie','scrollbars=yes,height=200,width=200'); printpop2 = printpop.document; if (window.focus) printpop.focus(); $(printpop2).ready(function(){ $("#printContent").append(code); });} Link to comment Share on other sites More sharing options...
justsomeguy Posted March 11, 2010 Report Share Posted March 11, 2010 I don't see the alerts there, you added them to the anonymous jQuery function? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now