Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

  1.  permalink
    It's getting down to the wire on a new online magazine site that I've been working on for the past couple months. I'm using Expression Engine on the back end, and for the most part, it's been great software.

    I have encountered a functionality issue that is a bit above my pay-grade and I need the help of a JS and/or PHP guru. I'm using Thickbox for the send to friend functionality; I'm pulling in the content of the layer with the email form through an iFrame. Go to this page and click the "Email a Friend" button to see the effect.

    Everything works great until the form is submitted and the iFrame redirects back to the original page that the user came from. I'd like the layer to close after successful form submission and the user receives the thank you page. Any ideas?

    If you find additional bugs (not fully compliant with IE6 yet), feel free to let me know as well.
    •  
      CommentAuthorJohnRiv
    • CommentTimeFeb 19th 2007
     permalink
    it appears that right now, if javascript is disabled, the URL of the iframe contains "TB_iframe=true" in the query string, but that value does not appear if javascript is enabled... so, on the 'email a friend' page, check if that value exists, and if it does not, pass some value through when the form is submitted so you know on the resulting page (the one that currently has the redirect) that the form was submitted via the thickbox iframe instead of a "normal" page (in which case you want the redirect). then on that redirect page, change the text to some sort of "thank you" text, and add this javascript to the page to close the thickbox window:

    top.TB_remove();

    that will close the thickbox window for you. then the only other decision is what to do with the now hidden thickbox window (since it will be displayed again if the user clicks the "email a friend" link without reloading the page)... do you keep it as a "thank you" page, or do you redirect page back to the email form... I'd probably redirect to the email form, but either option works.
  2.  permalink
    Thanks John - that was exactly what I needed.

    I was experimenting with placing the function on the submit button (Expression Engine's templating makes accessing the form code more trouble than it's worth sometimes), but the form wasn't going through.

    I ended up placing the function on the Thank You page. Unfortunately, due to another restriction of EE, the "Thank You" and "Error - Form didn't validate" pages are coming from the exact same template. So the iFrame closes whether the form was successfully sent of not. It's working for now, but ideas on a more elegant solution are welcome.

    Thanks again!
    •  
      CommentAuthorJohnRiv
    • CommentTimeFeb 19th 2007 edited
     permalink
    instead of calling top.TB_remove(); outright, add some logic to check for either an element that exists on the "Thank You" page but not on the "Error" that you can get to by document.getElementById, or maybe the page titles are different you can check for that (document.getElementsByTagName("title")[0].innerHTML), or at the very least, get the innerHTML of whatever element contains the "Thank You" or "Error" text, and check if that text contains "Error" (use indexOf() or a regex... i'd go with the indexOf cuz it's easier)... if it does contain "Error", don't close thickbox, and if it doesn't, then close it.
Add your comments
    Username Password
  • Format comments as (Help)