Javascript using window.location seems to lose state


Posted on 16th Feb 2014 07:03 pm by admin

Not sure what forum so let me know if I'm in the wrong place. I have a main window with a ajax grid that has a column of links that uses javascript and window.location to go to another page to show check stub information. When I use the backbutton on the browser everything persists on main window. Ok so far. If I navigate to the window with the show check stub information, there is a 'Print' button that again thru javascripts prints the grid with the check info on it. (Code I got of the internet with some minor changes I made).view plaincopy to clipboardprint?function Print() { var curVisible = true; var grid_obj = document.getElementById('<%= grdVoucherDetail.ClientID %>'); for (var i = 1; i < grid_obj.rows.length-1; i++) { grid_obj.rows[i].cells[8].style.display = curVisible ? "none" : "inline"; grid_obj.rows[i].cells[9].style.display = curVisible ? "none" : "inline"; } if (grid_obj != null) { var new_window = window.open('print.html'); //print.html is just a dummy page with no content in it. new_window.document.write(grid_obj.outerHTML); new_window.document.close(); new_window.focus(); new_window.print(); new_window.close(); } curVisible = false; for (var i = 1; i < grid_obj.rows.length-1; i++) { grid_obj.rows[i].cells[8].style.display = curVisible ? "none" : "inline"; grid_obj.rows[i].cells[9].style.display = curVisible ? "none" : "inline"; } } function Print() { var curVisible = true; var grid_obj = document.getElementById('<%= grdVoucherDetail.ClientID %>'); for (var i = 1; i < grid_obj.rows.length-1; i++) { grid_obj.rows[i].cells[8].style.display = curVisible ? "none" : "inline"; grid_obj.rows[i].cells[9].style.display = curVisible ? "none" : "inline"; } if (grid_obj != null) { var new_window = window.open('print.html'); //print.html is just a dummy page with no content in it. new_window.document.write(grid_obj.outerHTML); new_window.document.close(); new_window.focus(); new_window.print(); new_window.close(); } curVisible = false; for (var i = 1; i < grid_obj.rows.length-1; i++) { grid_obj.rows[i].cells[8].style.display = curVisible ? "none" : "inline"; grid_obj.rows[i].cells[9].style.display = curVisible ? "none" : "inline"; } }
Now after the print and closing that popup I click the backbutton again and things don't seem to persist. I did notice that the pageload of the main window (one I'm going back to) gets triggered after the printing of the grid where if I don't click the print button and go back the pageload does not get triggered. Any ideas would be appreciated. I have searched and searched for an answer and am getting nowhere. When this happens I usually feel that I've done something stupid. Oh well Thanks for any help that you can give me

No comments posted yet

Your Answer:

Login to answer
87 Like 21 Dislike
Previous forums Next forums
Other forums

echo $rows help
Hi all,

Hopefully something simple that I don't know!

I have this:

Code: [Selec

Number Format
Hi All,

I have number '000000000050085' I want to format it to 500.85 Can any one give me

LIMIT $start, 10... how to pass last value queried into next page with GET??
Ok I know how to display the first or last 10 results of a query...

$result = mysql_query(&q

Delete HTML file after loading
I have limited experience with php and its been a year or two since I've last used it. I have a sma

Multidimensional $_POST
Hello

How to get a single array from array of array (2 - dimension).
For example I have a

MySQL Primary key gap
Alright, so I have a table with 26 entries in it (id, filename, caption) for my image randomiser (ht

post to self
Trying to get my form to submit to itself. However I am also trying to use an image for my submit bu

Internal Server Error issues
This has been bothering me for weeks and I've been trying to solve it without asking for help, but e

Please help with SMTP Authenticated PHP Email Form
Hello, I'm creating a PHP email form, and for this particular server, I have to use SMTP Authenticat

Compare user input to flat file data
Help...Am a complete newbie to programming so my code is prolly quite long. Am trying to verify a us

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash