Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh the page if user comes from facebook

Status
Not open for further replies.

tyutghf

Technical User
Apr 12, 2008
258
0
0
GB
I am using a facebook app to display a facebook themed version of the webiste within a facebook tab. This works fine.

The problem is when I want to link to the main site (not in the app, but via an update or in the about page for example) that should take the user away form facebook and to the main website.

facebook doesn't link directly to webpages, they pass the url through a script first which is confusing my website into thinking the page is within the app and displaying the facebook version of the website.

So for example, a facebook visitor clicks the link to open the main website, they are prsented with the facebook version.

I made a getaround for the homepage using javascript, a simple refresh of the page loads the correct website. So I created a landing page /fb/ containing just

Code:
<script type="text/javascript">
window.location.href="[URL unfurl="true"]http://www.mywebsite.com"[/URL]
</script>
<noscript>
<meta http-equiv="refresh" content="0;url=http://www.mywebsite.com" />
</noscript>

But I now want to link directly to other pages. Can I put similar javascript into the header on every page, if the user comes from facebook (so I guess the url contains the word facebook) to refresh the page, otherwise do nothing?

Thanks
 
if you can get the QueryString through you can pass a NextURL in there and then use that to redirect people to the correct page.

Code:
var myURL = "[URL unfurl="true"]http://www.mysite.com/fb/index.html?NextURL=www.news.bbc.co.uk[/URL]

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Unfotunately I can't, when you type a link facebook creates a preview with link and strips out the querystring
 
Hi

tyutghf said:
facebook creates a preview with link and strips out the querystring
Then use path info instead of query string :
JavaScript:
var myURL = "[URL unfurl="true"]http://www.mysite.com/fb/index.html/NextURL/www.news.bbc.co.uk"[/URL]
If using Apache see the [tt]AcceptPathInfo[/tt] directive.

Feherke.
[link feherke.github.com/][/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top