how to reload a page using javascript with out alert

Please support our JavaScript / DHTML / AJAX advertiser: 50% off 6 Months Dedicated Server Hosting from 1&1!
Thread Solved

Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

how to reload a page using javascript with out alert

 
0
  #1
Aug 18th, 2008
hi,
iam using the following javascript a page
opener.location.reload( true );
but every time the page reloads iam a getting alert message.
How can i reload a page with out a alert message
If u r query is achieved,mark the thread as solved

Live and Let Live
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 12
Reputation: green2go is an unknown quantity at this point 
Solved Threads: 2
green2go green2go is offline Offline
Newbie Poster

Re: how to reload a page using javascript with out alert

 
0
  #2
Aug 18th, 2008
Originally Posted by greeny_1984 View Post
hi,
iam using the following javascript a page
opener.location.reload( true );
but every time the page reloads iam a getting alert message.
How can i reload a page with out a alert message
Tested your code replacing 'opener' with 'window' and I get no prompt! Whats the alert message saying?

Could be that your posting data to the page and then trying to refresh it?

Green2go
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

Re: how to reload a page using javascript with out alert

 
0
  #3
Aug 19th, 2008
i have two pages one is parent page and other child page.when i click on hyperlink in parent page,the child page should open and on clicking submit button in child page,the page should close and reload the parent page.Thats y iam using opener.location.reoload(true).
iam getting the follwong error
"The page cannot be refreshed without resending the information.click retry to send the information again,or click cancel to return to the page that you were trying to view."
If u r query is achieved,mark the thread as solved

Live and Let Live
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 383
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 35
langsor langsor is offline Offline
Posting Whiz

Re: how to reload a page using javascript with out alert

 
0
  #4
Aug 19th, 2008
That alert is basically stating that you submitted a form and by reloading the page you are going to resubmit the same data from the form (again).

This might work to not reload the page but reload the location ... let me know if it works
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. window.location.href = window.location.href;
  2. // or ...
  3. window.location.href = 'same_page.html';

Cheers
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

Re: how to reload a page using javascript with out alert

 
0
  #5
Aug 19th, 2008
Basically my need is when a click edit button in parent page,i need to open a child page . After filling the data in the child page and clicking submit in child page,the child page should close and update the parent page.
When i use as u stated location.href, the page is not getting updated.
If u r query is achieved,mark the thread as solved

Live and Let Live
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 383
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 35
langsor langsor is offline Offline
Posting Whiz

Re: how to reload a page using javascript with out alert

 
0
  #6
Aug 19th, 2008
I think I see what you're trying to do now.

parent.html
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. // open your pop-up window ...
  5. var pup = window.open('pup.html','pup');
  6.  
  7. function populate_form ( val1, val2 ) {
  8. pup.close();
  9. var form = document.getElementById('my_form');
  10. for ( var i = 0; i < form.elements.length; i ++ ) {
  11. var element = form.elements.item(i);
  12. switch ( element.name ) {
  13. case 'field_1': element.value = val1; break;
  14. case 'field_2': element.value = val2; break;
  15. }
  16. }
  17. }
  18.  
  19. </script>
  20. </head>
  21. <body>
  22. <form id="my_form">
  23. <input type="text" name="field_1" />
  24. <input type="text" name="field_2" />
  25. </form>
  26. </body>
  27. </html>

pup.html
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function send_to_parent ( target ) {
  5. var val1 = target.getAttribute('val1');
  6. var val2 = target.getAttribute('val2');
  7. opener.populate_form( val1, val2 );
  8. return false;
  9. }
  10. </script>
  11. </head>
  12. <body>
  13. <a href="javascript:" val1="one" val2="two" onClick="send_to_parent(this)">Populate 'one','two'</a><br />
  14. <a href="javascript:" val1="three" val2="four" onClick="send_to_parent(this)">Populate 'three','four'</a>
  15. </body>
  16. </html>

I think something like this is what you're looking for ... let me know if it works for you.

:-)
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

Re: how to reload a page using javascript with out alert

 
0
  #7
Aug 19th, 2008
hi,
Thanks for the quick reply,but i want to update the whole page.
If u r query is achieved,mark the thread as solved

Live and Let Live
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

Re: how to reload a page using javascript with out alert

 
0
  #8
Aug 19th, 2008
The suggestion u gave is very nice.
If u r query is achieved,mark the thread as solved

Live and Let Live
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 383
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 35
langsor langsor is offline Offline
Posting Whiz

Re: how to reload a page using javascript with out alert

 
0
  #9
Aug 19th, 2008
Originally Posted by greeny_1984 View Post
hi,
Thanks for the quick reply,but i want to update the whole page.
I think you can effectively target the parent window with the child form-action ...

parent.php (parent file name)

child.html
  1. <head>
  2. <script type="text/javascript">
  3. window.onload = function () {
  4. var form = document.getElementById('child_form');
  5. form.onsubmit = function () {
  6. self.close();
  7. };
  8. };
  9. </script>
  10. </head>
  11. <body>
  12. <form id="child_form" action="parent.html" method="POST">
  13. ... form input goes here
  14. </form>
  15. </body>

Then in the parent window you will need to detect if it is getting form values passed to it
  1. <?php
  2. if ( count( $_POST ) ) {
  3. // grab all the posted values here
  4. $val1 = $_POST ['val1']; // etc ...
  5. }
  6. ?>
  7. <html>
  8. <head>
  9. </head>
  10. <body>
  11. ... update the parent with child values
  12. <input type="text" name="val1" value="<? print $val1 ?>" />
  13. ... or whatever values you need to update on the parent page
  14. ... using inline <? print $value ?> PHP tags
  15. </body>
  16. </html>

Hope this makes sense
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

Re: how to reload a page using javascript with out alert

 
0
  #10
Aug 19th, 2008
Thanks langsor,
but iam not working on php
If u r query is achieved,mark the thread as solved

Live and Let Live
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum


Views: 9965 | Replies: 12
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC