User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 330,371 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,972 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 477 | Replies: 6
Reply
Join Date: Aug 2007
Posts: 68
Reputation: tanha is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster in Training

Redirect page function problem with Firefox browser

  #1  
8 Days Ago
Hi everybody,
I am using a java script function which redirect to the page according to the given parameter, and it is working as desired in IE, but I found that it not work with Firefox browsers, so some one plz guide me how it is possible to have the same function which could work on IE and Mozilla firfox.

The function code:

<?php
function reDirect($page)
{
     $s = "<script language = 'javascript'>
     window.navigate('$page');
     </script>";
     return $s;
}

Thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,611
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 21
Solved Threads: 297
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Redirect page function problem with Firefox browser

  #2  
5 Days Ago
There is no navigate function for the window object. Maybe try something like:
<?php
function reDirect($page)
{
     $s = "<script language = 'javascript'>
     window.location.href = '$page';
     </script>";
     return $s;
}
Last edited by ~s.o.s~ : 5 Days Ago at 1:21 pm.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: May 2008
Location: New Zealand
Posts: 12
Reputation: Mohan0704 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Mohan0704's Avatar
Mohan0704 Mohan0704 is offline Offline
Newbie Poster

Re: Redirect page function problem with Firefox browser

  #3  
3 Days Ago
You could just use a meta command (like this):

<meta http-equiv="refresh" content="##; *.html" />

where ## is a number of how long to keep the visitor here until the *.html where * is the name of the page is there. In other words, it simply redirects a user to another page.

history.go(0) also works and refreshes the page, but doesn't redirect.

so window.location.href="*" is the best to try.

another way is location.href which omits the 'window.' part of it
Reply With Quote  
Join Date: Sep 2005
Posts: 557
Reputation: digital-ether will become famous soon enough digital-ether will become famous soon enough 
Rep Power: 5
Solved Threads: 33
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Posting Pro

Re: Redirect page function problem with Firefox browser

  #4  
3 Days Ago
Originally Posted by tanha View Post
Hi everybody,
I am using a java script function which redirect to the page according to the given parameter, and it is working as desired in IE, but I found that it not work with Firefox browsers, so some one plz guide me how it is possible to have the same function which could work on IE and Mozilla firfox.

The function code:

<?php
function reDirect($page)
{
     $s = "<script language = 'javascript'>
     window.navigate('$page');
     </script>";
     return $s;
}

Thanks


Unless there is a specific need for using javascript, you could redirect the browser using HTTP headers.

  1. <?php
  2.  
  3. function reDirect($page)
  4. {
  5. header("Location: $page"); // tell the browser to go to the new location..
  6. die; // die so we can flush http output immediately
  7. }
  8.  
  9.  
  10. ?>
Last edited by digital-ether : 3 Days Ago at 5:05 am.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Join Date: May 2008
Location: New Zealand
Posts: 12
Reputation: Mohan0704 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Mohan0704's Avatar
Mohan0704 Mohan0704 is offline Offline
Newbie Poster

Re: Redirect page function problem with Firefox browser

  #5  
3 Days Ago
Isn't the die function the same as the exit function? Also, you can put a message to show people that the program is exiting
such as:
exit ('The program is exiting')
and
die ('The program is dying')
I give people ideas, not answers.
It's a common answer.
That's a idea to think on.
Reply With Quote  
Join Date: Sep 2005
Posts: 557
Reputation: digital-ether will become famous soon enough digital-ether will become famous soon enough 
Rep Power: 5
Solved Threads: 33
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Posting Pro

Re: Redirect page function problem with Firefox browser

  #6  
3 Days Ago
Originally Posted by Mohan0704 View Post
Isn't the die function the same as the exit function? Also, you can put a message to show people that the program is exiting
such as:
exit ('The program is exiting')
and
die ('The program is dying')


I believe they are the same.

The user would never see the message however under normal circumstances.

Its always good to add a bit of HTML explaining whats happening however, and add the JS that will redirect in case the browser fails to do a HTTP redirect.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,611
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 21
Solved Threads: 297
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Redirect page function problem with Firefox browser

  #7  
3 Days Ago
> You could just use a meta command (like this):

The W3C actually recommends against the use of such tricks for redirection. If Javascript is not a must, Digital Ether's suggestion seems good enough.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Marketplace (Sponsored Links)
Thread Tools Display Modes

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

All times are GMT -4. The time now is 10:24 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC