Welcome Guest, Not a member yet? Register   Sign In
auto go back?
#1

[eluser]Jumps Like A Black Guy[/eluser]
I dont know if this is possible.

I want to know if I can set an auto go back, for different instances?

This is what I mean...

The way the success/error messages display on my site are like this

Code:
<h2>&lt;?php echo $this->lang->line('Message_Display');?&gt;</h2>
                            
                             &lt;?php
                                //Show Flash Message
                                if($msg = $this->session->flashdata('flash_message'))
                                {
                                    echo $msg;
                                }
                               ?&gt;
                            &lt;!--<p align="center">&lt;input type="button" name="goback" class="clsGoBack" value="&lt;?php echo $this-&gt;lang->line('Go Back'); ?&gt;" onclick="history.go(-1)"/></p>--&gt;

If you noticed in the code above they put &lt;!-- --&gt; around the go back button. I tried it because I was wondering why they wern't using it. I found out it doesn't work in a lot of ways.

For instance, when a user logs out a success message shows with the go back button which is a bad idea. Or when a user is logged in and say they just edited there profile, a success message shows up with the back button which is only useful if the user messed up.

Long story short I want to set auto go backs with javascript...

Im guessing this can be done with else statments, but im not sure. When a user is not logged in I dont mind the back button, but I'd like it if when a user is logged in, and say they edit there profile, etc. When they see the success/error message I'd like to auto go back to member account home page, etc.

I know this is long, but im trying to explain what im thinking at the moment the best i can.
#2

[eluser]Jumps Like A Black Guy[/eluser]
So! No one knows? I'll keep looking to see if I can find an answer.
#3

[eluser]teampoop[/eluser]
So there are certain situations, or controls, that exist where you do not want the view to display the 'goback' functionality? I would recommend setting a key in your $data that you test again. If that key !exists, show button or script block, else don't... I've done auto backs before and what I do is set a function in my main js, call it goback(), that has a settimeout and then does the history.go(-1) inside. Then just create your block that exists only if !$data[dontgoback].

js:
Code:
function goback() {
  window.setimeout(function(){history.go(-1);}, 500);
}

view:
Code:
<h2>&lt;?php echo $this->lang->line('Message_Display');?&gt;</h2>

&lt;?php
  //Show Flash Message
  if($msg = $this->session->flashdata('flash_message'))
  {
    echo $msg;
  }
?&gt;
&lt;?php
  // look for dontgoback;
  if(!$dontgoback)
  {
?&gt;
[removed]
  goback();
[removed]
&lt;?php
  } // end of goback look
?&gt;

hth




Theme © iAndrew 2016 - Forum software by © MyBB