Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 44
07-06-2013, 10:26 AM #1
best way to display alert on referring page
Hi i have a process that displays success alert but i would like to display that alert on the referring page which is still in view on the browser.
i know how to get the referrer,
var referrer = document.referrer;
but how do i tell the alert to display on that referring page.
07-06-2013, 11:56 AM #2
The more i look at my process the more it is not that bad, i guess i am being a bit too picky. It is just fine because i refresh the page anyway one the confirm alert. So for a moment they are looking at an alert and a blank page but i guess thats ok.
Anyway i am still curious however if anyone can point me in the right direction on some docs for this.. just for the sake of learning
07-06-2013, 04:51 PM #3
- Join Date
- Jan 2011
- Thanked 667 Times in 666 Posts
Not sure what the success alert is heralding and where you are moving to after leaving the page. Hope it's not seccess at going to the right page
You could determine your success on the page via JS and give the thumbs up before moving on, you could use ajax to determine the success, flash the 'success alert' and then move on.
But trying to do it from the next page just seems to cause problems.
Evolution - The non-random survival of random variants.
"If you leave hydrogen alone, for long enough, it begins to think about itself."
07-06-2013, 06:11 PM #4
It sounds to me like a query string is what you're looking for
07-06-2013, 06:18 PM #5
thanks sunfighter yeah i agree... and thanks xelawho
to give an example it is much like the login in process for this coding forums site. do you notice the redirect when you first log in and that white page behind the notice. That is the same white page behind my alert.
So this process is, and fyi this is for a mp3 upload, no database, all folder driven so its easy peasy lol..
1. they are looking at the player and song list display (main page).
2. below that is the upload html form
3. they choose the song they want to upload and press the button
4. it processes in a php file (the only output is the alert - no other output just process and redirect back)
5. on success (file uploaded) or failure (error control) they get an alert (in the middle of the white page i spoke of)
6. when they click OK on the alert it redirects them back to the original page they were on. (i refresh the page regardless so the new song will be on the list)
So to clarify a bit if they could stay on the same page and just show the alert and refresh that same page without the white page in the interm it would look cleaner. It does work and it is fully functional, im just thinking it would appear to be a cleaner process to the user without the white page involved in the process and just have the alert show up on the main page.
The challenge is that the main page is a page that has been added using a internal script page add process and it will only handle html, no php, no js so i cannot put the js on the page display which would be perfect. To be specific, its an oxwall page that has been added thru admin page add using iframe and html form.
So basically the only change would be to take away the white page but i dont see how that is possible with the alert in the other file.
We would have to have something like this i guess if it even exists.
var refr = document.referrer;
(window.location.href = refr + alert('job done'));
07-06-2013, 09:23 PM #6
Oh - ha,ha. Sorry - I was imagining pretty much the exact opposite of what you're trying to do. Sounds like ajax might be of some use
07-07-2013, 01:06 AM #7
Thanks i thought of that as well, but even if i had a ajax listener i could not put it on the main page as it does not allow anything but html. So it would end up being the same as what i have.
Short of naming the iframe and having the alert diplay (passing it to) the iframe i am thinking the closest i could possibly come is to use window open and open a small window just big enough for the alert and have the alert display inside that, then i could direct the window to open in the middle of the page, at least they could still see the page they are on even though its pretty much the same just a variation. But that is sort of hokey too.
tough to imagine with all the functions and cirumstances that noone has ever had to direct an alert to a specific page. Maybe im the first lol...
07-07-2013, 01:15 AM #8
- Join Date
- Sep 2005
- Sydney, Australia
- Thanked 663 Times in 652 Posts
Since you are going to need to build your "alert" from HTML anyway, it really ought to be built into the HTML of whatever page is going to display it - and then simly un-hide it when you want it to display.
07-07-2013, 03:44 AM #9
Thanks Felgall, I was not aware the js alert() was for debugging i have used it for a long time. And i guess i need to do some digging as i have never heard of doing an alert in html, the closest is document.write that thats still js.
I will hit google and see what i can find.
I did remove the process from the main site and slapped together a quick demo. If you upload a song you can see exactly what i mean, pretend the page your on will only take html and thats it, no js, ajax, just html.
The alert you get is actually comming from the very last part of the php process page.
here is the demo http://www.anorexiadating.com/mp3demo/index.html
07-07-2013, 12:40 PM #10
Also dont you have to have a document to do
what i mean is that if someone accesses my php file directly and no form post then there technically is no document, correct?Code:document.referrer;
What i am doing is in this case, when they try to access the php file directly i am doing a js redirect to google after telling them thats a no no..
but it is not capturing the ref, so im guessing its because the ref is blank or i need to actually come from somewhere to get it, hense no document.
07-07-2013, 04:04 PM #11
I get a 403 error on that link.
This may be getting a little obvious, but if you can only add html, possibly you can add an external script using <script> tags?
07-07-2013, 06:07 PM #12
Sorry about that xelawho, i have an extensive list of blocks in my htacess and i guess somehow your ip was blocked. Its just one of those things it happens, i knew i could not do that without possibly blocking valid visitors but i had to do something and nothing is full proof so im sorry about that.
07-07-2013, 06:51 PM #13
no need to apologise, but if it's blocking me then it will block other legitimate users, so you may want to rethink that one.
but anyway, did the <script> tag not work?
07-07-2013, 09:35 PM #14
no sir, sadly it did not, it did not im sure they have stripped that from being executable somehow.
07-07-2013, 09:43 PM #15
Users who have thanked xelawho for this post: