Sunday 15 May 2011

javascript - Window.open within php while loop not functioning correctly -


I have a time loop that creates several tables with inside information. Each table has a Facebook and Twitter icon I can share a reader's information or tweet the information that is in the table through an onclick event.

This is every event

    

The strange thing is that it works. to some extent. When I click on the FB icon in a small window, the dialogue will pop up, the same problem for twitter is that when I look at the top header of the popup ... it is using the same information from all the tables is.

What do I want ...

Table 1 FB

Table 3 .. etc etc etc

But when I click on the icon Table 1: Window opens (GOOD)

Table 2: Window opens ... (BAD)

Table 3: The window opens ... (BAD)

It looks like a simple SQL issue but when I pull the page source I

Table 1

  & lt; Script type = "text / javascript" & gt; Function tweet () {var sharer = "https://twitter.com/intent/tweet?source=webclient&text=random title - http://www.makeupsite.com/post.php?id=39"; Window.open (Sharer, 'Sharer', 'width = 600, height = 500')}} & lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Function FBS Share () {var share = "https://www.facebook.com/sharer/sharer.php?u=http://www.makeupsite.com/post.php?id=39"; Window.open (Share, 'Share', 'Width = 600, Height = 500');} & lt; / Script & gt;   

Table 2

  & lt; Script type = "text / javascript" & gt; Function Tweet () {var sharer = "https://twitter.com/intent/tweet?source=webclient&text=random title - http://www.makeupsite.com/post.php?id=43"; Window.open (Sharer, 'Sharer', 'width = 600, height = 500')}} & lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Function FBS Share () {var share = "https://www.facebook.com/sharer/sharer.php?u=http://www.makeupsite.com/post.php?id=43"; Window.open (Share, 'Share', 'Width = 600, Height = 500');} & lt; / Script & gt;   

Actually the page source is saying one thing ... but window The Open is doing something completely.

You are defining the same function again and again again. Depending on the browser, you will always define first or last tweet () or FBS-HYE ().

In the footer of your document, set a single function:

  function share link (targetURL) {window.open (targetURL, 'share', 'width = 600, height = 500 '); }   

After that, tie on your social buttons:

  onclick = shareLink ("[twitter URL here]");   

or

  onclick = shareLink ("[Facebook URL here]");   

See what I'm doing?

Edit Whoops helps me find the correct name

No comments:

Post a Comment