Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How could I do a redirect to this URL after my user clicks on the button?

Posted on 2012-08-19
4
Medium Priority
?
418 Views
Last Modified: 2012-08-27
I've got a button that my user can click on that opens up a pop up window. You can see the code below. I want to keep track of when that user clicks on the button and I thought I would have a situation where rather than opening up the pop up window right away, I would first direct my user to a page where the database is updated and then redirect it to the original pop up address.

How would I do that?

So here's the code that I have right now:

<a href="#" onclick="FB.ui({method: 'feed',name: 'I just voted!', link: 'https://apps.facebook.com/texaco_songwriting/', picture: 'http://www.countryshowdown.com/songwriting/images/facebook_news_feed.jpg', caption: 'Texaco Country Showdown Songwriting Contest', description: 'I just voted for <?php echo $display_name; ?> on the Texaco Country Showdown Songwriting Contest' }); return false;"><IMG SRC="images/news_feed_button.jpg" border="0"></a>

How could I change that so my user goes to a page where I do my database stuff and then redirect them to the window that you see referenced above?
0
Comment
Question by:brucegust
  • 2
4 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 750 total points
ID: 38310663
An alternative you could use is to just trigger the database seperately from the popup window.

<a href="#" onclick="trackVote(event, this, '<?=htmlspecialchars($display_name);?>');FB.ui({method: 'feed',name: 'I just voted!', link: 'https://apps.facebook.com/texaco_songwriting/', picture: 'http://www.countryshowdown.com/songwriting/images/facebook_news_feed.jpg', caption: 'Texaco Country Showdown Songwriting Contest', description: 'I just voted for <?php echo $display_name; ?> on the Texaco Country Showdown Songwriting Contest' }); return false;"><IMG SRC="images/news_feed_button.jpg" border="0"></a>

Open in new window


Then include a trackVote function:
<script type="text/javascript">
function trackVote(event, link, displayName) {
     var img = document.createElement('img');
           img.style.display = 'none';
           img.src = '/track.php?displayName=' + encodeURIComponent(displayName) + '&random=' + Math.random();
     document.body.appendChild(img);
}

Open in new window


Kind regards,

-r-
0
 

Author Comment

by:brucegust
ID: 38311178
Problem is, I don't have access to the Facebook window itself in that I can't add any script to that part of the challenge. I've got to do my database stuff first, before my user goes to the Facebook interface.

What do you think?
0
 
LVL 18

Assisted Solution

by:nap0leon
nap0leon earned 750 total points
ID: 38311356
I was going to post some code, but it largely mirrors Roonan's approach.

In the onclick of the link on YOUR page, make a call to a page on your site that does the database stuff, THEN call the FaceBook stuff.  Your concern about not having access to FB's site is moot - this is a change to YOUR page.
0
 

Author Comment

by:brucegust
ID: 38311534
Nap0leon, that sounds right. Could you give me an example or point me to an online resource that shows me how to faciliate two actions as far as the onclick that does my database stuff then automatically proceeds to the Facebook dynamic.

I'm not wanting you to do the work for me and I want to learn not just copy and paste, but if you could give me a starting point, that would be just a little bit of awesome.

I appreaciate your time...
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question