News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

redirectexit out of an Iframe

Started by CaptainKirk, May 19, 2009, 12:01:54 AM

Previous topic - Next topic

CaptainKirk

Ok, this is probably a dumb question, but here goes.  I have my forum inside an Iframe.  I want to redirect people that attempt to register (by selecting the Register menu item) to be redirected to a different registration page.  I can get everything to work by changing Register.php to read
redirectexit('http://mysite.com/Registration.html)');
where needed.  However, I want to exit the Iframe.  I'm assuming that this is possible, but I can't find anything searching the forum here.

Any help would be appreciated.

tyty1234

The function redirectexit is used to redirect users to another forum action (e.g. redirectexit(action=forum)). If you want to redirect them to somewhere else, you might want to use the header method. (header("Location: http://newsite.com"))

Just make sure the header is called before any output (echo, print, etc)
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

H

tyty1234, AFAIK redirectexit() already uses header()?

I believe you'd need to modify the redirect exit function to use meta redirect instead of header() which is slowly and more clunky. Ideally you'd want to just not use an iframe! Instead search this forum for integrating SMF into your site. You can add the relevant bits of your site template into SMF, so that there is no longer a reason to use a frame.
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

tyty1234

My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

CaptainKirk

Thanks guys.  Sorry for not getting back to you sooner.  I've been out-of-pocket the last week and things got put on a far back burner.  I'll check out your implementation suggestions and see how things work. 

robinrobin

#5
I tried adding the _top stuff after "?action=register" in Subs.php,:

'register' => array(
'title' => $txt['register'],
'href' => $scripturl . '?action=register',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),


But clicking the register button only leads me to the index page of the forum then. I noticed that the URL turns into this when you use double-apostrophes:

/index.php?action=register target=

I tried using this instead:

'?action=register target=\'_top\''

And it showed up as:

/index.php?action=register target='_top'

But that produced the same result. So how can you create double-apostrophes in PHP ?

robinrobin

Hurray for Arantor!

The "target" code doesn't even show up in the link now, but i guess that's the point then!

Thank you!

robinrobin

Oh, it sure does! Having the forum in an iframe on my site and clicking on Register in that iframe makes the Registration page load "over" the parent-page. Then simply changing the redirectexit to the URL of the main page again (which shows the forum in an iframe) makes the browsers of new registrars send them to the main page as soon as they hit "Register", though now with the problem i previously had out of the way; the navigation-bar in the parent frame not updating its buttons according to a logged in user.

The fact that SMF logs users in as soon as they click "Register" (if you don't require any account activations) makes this a very practical solution in my case, since they clearly can see that they actually are logged in now when they see the differences in the navigation-bar at the top, even though they at first might be a little confused why they got sent back to the main page without any confirmation. They'll get it. =)

Perhaps you could assist in what code to add if someone wants a confirmation pop-up to appear via the redirectexit code as well though?

robinrobin

Arantor, i don't need this function for when someone enters the registration page, but when they leave it (by clicking the Register button.) I tried adding this code to redirectexit and it doesn't work. It just makes going go the URL in it not work, as if the redirectexit code doesn't exist.

redirectexit('onclick="javascript:return confirm(\"Do you wish to proceed?\");"http://www.website.com');

Maybe it should be added to the actual "Register" button?

Advertisement: