Costanza Posted November 6, 2011 Share Posted November 6, 2011 Hi, not an error this time, I've just got a question on methodology: I want to have a user click a button which opens a new window that has info on it that was based on factors from the original page. The idea is that the user is assembling parts on the original page, then when they click this button the names of all those parts will be listed in a simple, printable format. (the info I am pulling from the first page are the title attributes of several divs) What would be the right way to go about this? As always, thank you! Link to comment Share on other sites More sharing options...
justsomeguy Posted November 7, 2011 Share Posted November 7, 2011 You need a way to collect the data they pick, and then either send the data to the new window or after the window is open you can use the data to update the new page however you want. Link to comment Share on other sites More sharing options...
ShadowMage Posted November 7, 2011 Share Posted November 7, 2011 You can access the other window's document property from the same script that opened said window. So it's just a matter of copying the data from one place to another: var newWindow = window.open(...);newWindow.document.getElementById("destinationElem").innerHTML = document.getElementById("sourceElem").title; EDIT: On second thought, the above probably wouldn't work because the new window needs to load before being able to access it's DOM. So you might need a script in the new document to run onload that accesses the information on the main page. The idea is the same, except you'll use the opener property to access the main page: document.getElementById("destinationElem").innerHTML = opener.document.getElementById("sourceElem").title; Another option, would be to create the entire DOM for the new window with JavaScript. If the new document is relatively simple, this might not be a bad idea. It would save creating another file to maintain as well as eliminating problems with accessing elements before they're loaded. If the new document is complex, though, you're probably better off creating another file. Link to comment Share on other sites More sharing options...
Costanza Posted November 8, 2011 Author Share Posted November 8, 2011 Thanks ShadowMage, that method works! (obviously with the changes to fit my intended needs) I'm getting into a fair amount of code and methods that I've never used before so I'm still learning how it all works. Been reading a lot of the entries on this site for objects and functions but sometimes you need human help for more complex issues. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.