Jump to content

Back button script


Recommended Posts

Ok so i was reading the rules just long enough to notice the previous post was deleted, which is fine (violated rules)...

 

I'm looking for some help with a script that will redirect users when they click the back button, obviously this isn't the most ethical of web practices but all i'm doing is creating the frame work I'm not particularly curious about what it will be used for.

 

The idea is that once the page is loaded and you click the back button it will redirect you to a new page; as i said its not the most ethical of web practices but its a task i was given, hence my reason for posting...

 

thanks for any help

Link to comment
Share on other sites

If you're looking for someone to do it, post it in freelance.  Otherwise post what you have.  No one is going to write it from scratch for you.

 

By the way, this is probably better handled via javascript, not PHP.

Link to comment
Share on other sites

Oh yes sorry about that, original post got deleted before i could update it ok I do have something working on and you're right its really through java script, the only reason i posted here is because the site will eventually be parsing php scripts but the functionality itself will be facilitated via javascript, the example i have uses a iframe to load the new page, the thing is though I can only get it to load one page what i'd like to do is have it loop through a number of pages....

 

Its attached below thanks

17229_.zip

Link to comment
Share on other sites

Yes I've established that, and as you might note there's no mention of doing it in php, granted this is a php forum and the pages will as i said parse php in the body, however the functionality at the top of the page which is of course as i said the back button requires that when a user clicks back they are sent to any number of pages... depending on how many times the redirect is set to occur, the file that i attached to the previous post does this once i want to do it more than once but its being a bit problematic, as such i'm looking a bit of assistance.

Link to comment
Share on other sites

Ok so i was reading the rules just long enough to notice the previous post was deleted, which is fine (violated rules)...

 

I'm looking for some help with a script that will redirect users when they click the back button, obviously this isn't the most ethical of web practices but all i'm doing is creating the frame work I'm not particularly curious about what it will be used for.

 

The idea is that once the page is loaded and you click the back button it will redirect you to a new page; as i said its not the most ethical of web practices but its a task i was given, hence my reason for posting...

 

thanks for any help

if you are talking about manipulating the browsers back button, it can't be done with JS.

 

Link to comment
Share on other sites

@ MasterACE14 Yes its a bit more complex than that

@ AyKay47 i had attached the file that i was working on and It was being done in javascript to be honest whichever one works works, if you look at the example though you'll see that i'm able to call a blank page in an iframe regardless of any prior content being loaded into history that functionality is fine the only thing wrong with that is that its limited to 1 page and i want to have the functionality for several different pages to be called on clicking the back button, I hope i'm being a bit clearer now :)

Link to comment
Share on other sites

Ok so i was reading the rules just long enough to notice the previous post was deleted, which is fine (violated rules)...

 

I'm looking for some help with a script that will redirect users when they click the back button, obviously this isn't the most ethical of web practices but all i'm doing is creating the frame work I'm not particularly curious about what it will be used for.

 

The idea is that once the page is loaded and you click the back button it will redirect you to a new page; as i said its not the most ethical of web practices but its a task i was given, hence my reason for posting...

 

thanks for any help

if you are talking about manipulating the browsers back button, it can't be done with JS.

 

 

It can, but it's a bit of a hack and not very reliable.

Link to comment
Share on other sites

Ok so i was reading the rules just long enough to notice the previous post was deleted, which is fine (violated rules)...

 

I'm looking for some help with a script that will redirect users when they click the back button, obviously this isn't the most ethical of web practices but all i'm doing is creating the frame work I'm not particularly curious about what it will be used for.

 

The idea is that once the page is loaded and you click the back button it will redirect you to a new page; as i said its not the most ethical of web practices but its a task i was given, hence my reason for posting...

 

thanks for any help

if you are talking about manipulating the browsers back button, it can't be done with JS.

 

 

It can, but it's a bit of a hack and not very reliable.

You can manipulate the history, not the functionality itself.

Link to comment
Share on other sites

Ok getting two different responses here lol but anyway...

 

@AyKay47 it is possible you can change the functionality, all that is required is for you to set a listener on the event that even being the back button being clicked and then direct it to the desired location, i can show you and example if necessary i cant post it though, its not allowed

 

@scootstah you are indeed correct about that sir i'm not a super duper expert but i'm not a noob either and i have been trying with varying levels of success to get this done if its ok I can send an example to you via pm, the page has mature content but its the only example that i've seen so far that works so unless there is a rule against that then i'd like to share, its not the most thrilling bit of code imo but i'm always up for learning new things....

Link to comment
Share on other sites

Ok getting two different responses here lol but anyway...

 

@AyKay47 it is possible you can change the functionality, all that is required is for you to set a listener on the event that even being the back button being clicked and then direct it to the desired location, i can show you and example if necessary i cant post it though, its not allowed

 

@scootstah you are indeed correct about that sir i'm not a super duper expert but i'm not a noob either and i have been trying with varying levels of success to get this done if its ok I can send an example to you via pm, the page has mature content but its the only example that i've seen so far that works so unless there is a rule against that then i'd like to share, its not the most thrilling bit of code imo but i'm always up for learning new things....

i don't need an example, i know very well what you can do with this, as i said, you can manipulate the history, my guess is this is to create an annoying popup or something of the sorts, which i'm not at means to help with.

Link to comment
Share on other sites

@ AyKay47 Its really quite nice that you've taken the time out to help me address this but, you dont understand the situation, I am not trying to create any annoying popups or anything of that sort, so please listen to what i'm saying before you flame my post. I only want help with a script that will on clicking the back button redirect the user to a specific page, This functionality has already been achieved and the example that i attached to the post you would see this in action the fact is sir we are all here to help each other out, if you are not inclined to do this then its fine, but please dont insult my intelligence i know what i'm talking about.

 

The fact is the script will not be loading any elements from the history cache, it will detect when the back button is clicked and send the user to a predefined url, if the user clicks back again, it will send them to another url. Weather or not you had cached a page before isnt the point the point is to catch the event being fired on clicking the back navigation in the browser and directing that action to a specific page or several pages for that matter...

Link to comment
Share on other sites

This functionality has already been achieved and the example that i attached to the post

So this is what happens when you download that attachment..  Although it says it is a zip file, named mail.zip, index.php is downloaded instead... When viewed with wordpad, this pops up.

 

 

In short, I see no example whatsoever. 

17232_.png

Link to comment
Share on other sites

Hello Zane I cant imagine what could have caused the server to rename it and change the extension but just one glance at the unicode would indicate that the files are still intact try changing the extension to .zip I'm really not sure what could have caused it though but I'm 100% sure that the correct file was uploaded hence It must have been an error in the upload or parsing of the files, the reason why I know is because I've had reason to write code that parsed files into Unicode and back to original format  just before download so i know what the Unicode looks like  either way sorry for the inconvenience

Link to comment
Share on other sites

I shouldn't have to change the extension on anything, especially if you're the one asking for help.  Why can't you just post your code within code tags like the rest of the population here.  Even if changing the extension does fix it on my end, it still sounds rather fishy.  I'm surprised I even downloaded it to begin with; curiosity got the best of me.

 

Post the relevant code or you will not receive quality help.  Questions shouldn't be instructions.

Link to comment
Share on other sites

I didn't change the extension and the only reason why i posted a compressed version is because there happens to be more  than one file including a minified .js script. Why does every one here jump to conclusions before asking, I have been a member of forums before both as a moderator and a user, I mean no disrespect Mr. Moderator but the underlying tone of this board is a far cry from being quality help, first i got flamed for creating popups, got told what i was doing was totally irrelevant or albeit impossible, now you're well you're not doing anything bad i suppose but you do get my point...

 

Considering that you've got it working, and it didn't eat your computer  can you now see the issue that i'm having and help me somewhat... :shrug:

 

I'm attaching the file again so as to clear any confusion, hopefully it remains intact

17235_.zip

Link to comment
Share on other sites

Within 5 seconds of posting the link it agains shows up as index.php The only thing left i suppose is to post a video showing the uploading process because as i said I did nothing to change the parameters of the file, Its a pure .zip file I clicked browse selected the file and clicked on post :shrug:

 

Am i missing something here???

Link to comment
Share on other sites

I didn't change the extension and the only reason why i posted a compressed version is because there happens to be more  than one file including a minified .js script. Why does every one here jump to conclusions before asking, I have been a member of forums before both as a moderator and a user, I mean no disrespect Mr. Moderator but the underlying tone of this board is a far cry from being quality help, first i got flamed for creating popups, got told what i was doing was totally irrelevant or albeit impossible, now you're well you're not doing anything bad i suppose but you do get my point...

 

Considering that you've got it working, and it didn't eat your computer  can you now see the issue that i'm having and help me somewhat... :shrug:

 

I'm attaching the file again so as to clear any confusion, hopefully it remains intact

 

I did not jump to conclusions.  I'm telling you that the average user, here or anywhere else, that has any sense at all, will unlikely download your attachment.  No one wants to download your file just like no one wants to wait 30 seconds on a file hosting server to get a hot download.  The key to getting quality help is to provide everything possible and/or needed to asses the question.

 

When you go to the mechanic do you ask the mechanic to go pick up your car and fix it? No, you either drive it there or have it towed so the mechanic can see it instantly, without any obstacles.

 

This same thing was said just earlier today

You will need to post a description of what your actual problem is (this doesn't work is not descriptive enough for us to be able to assist you). It's always best to post the relevant code directly within your post using


tags. People won't often download code.

 

Regardless. I changed the extension anyway.. just to see ... something.  What I found was a third party javascript file.  Here, I'll even post it for you

/*!
* Back Button Detection Object V 1.0.1
* http://www.brookebryan.com/
*
* Copyright 2010, Brooke Bryan
*
* Date: Thu 27 Jan 2011 13:37 GMT
*/

var bajb_backdetect = {
Version: '1.0.0',
Description: 'Back Button Detection',

Browser: {
	IE:     !!(window.attachEvent && !window.opera),
	Safari:	navigator.userAgent.indexOf('Apple') > -1,
	Opera:	!!window.opera
},

FrameLoaded: 0,
FrameTry:0,
FrameTimeout: null,

OnBack: function(){
	/*alert('Back Button Clicked');*/
},

BAJBFrame: function(){
	var BAJBOnBack = document.getElementById('BAJBOnBack');
	if(bajb_backdetect.FrameLoaded > 1)
	{
		if(bajb_backdetect.FrameLoaded == 2)
		{
			bajb_backdetect.OnBack();
			history.back();
		}
	}
	bajb_backdetect.FrameLoaded++;
	if(bajb_backdetect.FrameLoaded == 1)
	{
		if(bajb_backdetect.Browser.IE)
		{
			bajb_backdetect.SetupFrames();
		}
		else
		{
			bajb_backdetect.FrameTimeout = setTimeout("bajb_backdetect.SetupFrames();",700);
		}
	}
},

SetupFrames: function()
{
	clearTimeout(bajb_backdetect.FrameTimeout);
	var BBiFrame = document.getElementById('BAJBOnBack');
	var checkVar = BBiFrame.src.substr(-11,11);

	if(bajb_backdetect.FrameLoaded == 1 && checkVar != "HistoryLoad")
	{
		BBiFrame.src = "blank.html?HistoryLoad";
	}
	else
	{
		if(bajb_backdetect.FrameTry 			{
			bajb_backdetect.FrameTry++;
			bajb_backdetect.FrameTimeout = setTimeout("bajb_backdetect.SetupFrames();",700);
		}
	}
},

SafariHash: 'false',
Safari: function()
{
	if(bajb_backdetect.SafariHash == 'false')
	{
		if(window.location.hash == '#b')
		{
			bajb_backdetect.SafariHash = 'true';
		}
		else
		{
			window.location.hash = '#b';
		}
		setTimeout("bajb_backdetect.Safari();",100);
	}
	else if(bajb_backdetect.SafariHash == 'true')
	{
		if(window.location.hash == '')
		{
			bajb_backdetect.SafariHash = 'back';
			bajb_backdetect.OnBack();
			history.back();
		}
		else
		{
			setTimeout("bajb_backdetect.Safari();",100);
		}
	}
},

Initialise: function()
{
	if(bajb_backdetect.Browser.Safari)
	{
		setTimeout("bajb_backdetect.Safari();",600);
	}
	else
	{
		document.write('');
	}
}
};
bajb_backdetect.Initialise();

Now, we can all see that you're using the Back Button Detection Object... supposedly found at http://www.brookebryan.com/

 

What exactly is the problem I ask now?  If it has anything to do with this script, which I have sneaking suspicion it does, then this thread belongs in Third Party Scripts.

 

Link to comment
Share on other sites

The script itself mimics the behavior that i want but it is inadequate, in that It only calls one page which is blank.html what In reality what I want is for the listener to pick up the action of clicking the back button, then redirect the user to a page or pages of my choosing, ordinary redirect methods would send the user to a new page before the contents of the original page is loaded which is not the idea, the redirect should only take place onClick of the back button :)

 

I can show you an example i just cant post the link would that be ok, and pardon the whiny behavior I've just always been keen on being respectful and polite regardless of the situation... 8)

 

Oh and that mechanic analogy was good only thing is that i sent a bimmer on the tow truck and when i got there (the mechanic) they had a Lada saying thats what i had sent

Link to comment
Share on other sites

Ok, this is what I understand so far:

 

- You want to listen for the click of the back button on the browser

- You have a 3rd party script that lets you do this

- Third, I see this

if(bajb_backdetect.FrameLoaded == 1 && checkVar != "HistoryLoad")
	{
		BBiFrame.src = "blank.html?HistoryLoad";
	}

- And four, you want to redirect to more than one page?

 

If that's the case, then could you not just setup an array, give it a random index, and then redirect?

 

EDIT: This is pretty much a shot in the dark, but wouldn't the onbeforeunload() function be what you're looking for?

http://msdn.microsoft.com/en-us/library/ms536907%28v=vs.85%29.aspx

Link to comment
Share on other sites

Yes, you are right up to the shot in the dark, the thing is I dont need any prompts on redirect, that aspect requires a seamless link between the pages and would be synced on each click of the back button additionally the call to the page that displays the information is a static call to one page so even with the array in place the calls would always call a single page i tried implementing a for with a case for each page but its not exactly working...

 

else
	{
		document.write('<iframe src="blank.html" style="display:none;" id="BAJBOnBack" onunload="alert(\'de\')" onload="bajb_backdetect.BAJBFrame();"></iframe>');
	}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.