Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 3 123 LastLast
Results 1 to 15 of 44
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,452
    Thanks
    275
    Thanked 32 Times in 31 Posts

    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,

    Code:
    var referrer = document.referrer;

    but how do i tell the alert to display on that referring page.

  • #2
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,452
    Thanks
    275
    Thanked 32 Times in 31 Posts
    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

    Thanks

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,679
    Thanks
    25
    Thanked 655 Times in 654 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."

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    It sounds to me like a query string is what you're looking for

  • #5
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,452
    Thanks
    275
    Thanked 32 Times in 31 Posts
    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..

    The user:
    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'));

  • #6
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    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

  • #7
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,452
    Thanks
    275
    Thanked 32 Times in 31 Posts
    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...

  • #8
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 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.

    The alert() function built into JavaScript itself is for debugging only as it displays additional checkboxes to aid in debugging. Most browsers will display one or other of the following checkboxes:



    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #9
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,452
    Thanks
    275
    Thanked 32 Times in 31 Posts
    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

  • #10
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,452
    Thanks
    275
    Thanked 32 Times in 31 Posts
    Also dont you have to have a document to do

    Code:
    document.referrer;
    what i mean is that if someone accesses my php file directly and no form post then there technically is no document, correct?

    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.

  • #11
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    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?

  • #12
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,452
    Thanks
    275
    Thanked 32 Times in 31 Posts
    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.

  • #13
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    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?

  • #14
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,452
    Thanks
    275
    Thanked 32 Times in 31 Posts
    no sir, sadly it did not, it did not im sure they have stripped that from being executable somehow.

  • #15
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts

  • Users who have thanked xelawho for this post:

    durangod (07-07-2013)


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •