bonjour tout le monde
je vous présente un code qui sert à partager une page dans tous les sites qui permettent le partage tel que facebook
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
if(!DT) DT={};
DT.share={
	list:new Array('scriptandstyle','blinklist','delicious','digg','diigo','reddit','yahoobuzz','stumbleupon','technorati','mixx','myspace','designfloat','facebook','twitter','twittley','linkedin','newsvine','devmarks','google','misterwong','friendfeed','blogmarks','yahoo','livefavorites','pixelgroovy','simpy','propeller','yigg','linkarena','hatena'),
	urlList:{
		scriptandstyle:'http://scriptandstyle.com/submit?url=PERMALINK&title=TITLE',
		blinklist:'http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url=PERMALINK&Title=TITLE',
		delicious:'http://del.icio.us/post?url=PERMALINK&title=TITLE;notes=DESC',
		digg:'http://digg.com/submit?phDTe=2&url=PERMALINK&title=TITLE&bodytext=DESC',
		diigo:'http://www.diigo.com/post?url=PERMALINK&title=TITLE&desc=DESC',
		reddit:'http://reddit.com/submit?url=PERMALINK&title=TITLE',
		yahoobuzz:'http://buzz.yahoo.com/submit/?submitUrl=PERMALINK&submitHeadline=TITLE&submitSummary=DESC&submitCategory=&submitDTsetType=',
		stumbleupon:'http://www.stumbleupon.com/submit?url=PERMALINK&title=TITLE',
		technorati:'http://technorati.com/faves?add=PERMALINK',
		mixx:'http://www.mixx.com/submit?page_url=PERMALINK&title=TITLE',
		myspace:'http://www.myspace.com/Modules/PostTo/Pages/?u=PERMALINK&t=TITLE',
		designfloat:'http://www.designfloat.com/submit.php?url=PERMALINK&title=TITLE',
		facebook:'http://www.facebook.com/share.php?u=PERMALINK&t=TITLE',
		twitter:'http://www.twitter.com/home?status=TWITTER_TEXT',
		twittley:'http://twittley.com/submit/?title=TITLE&url=PERMALINK&desc=DESC&pcat=&tags=',
		linkedin:'http://www.linkedin.com/shareArticle?mini=true&url=PERMALINK&title=TITLE&summary=DESC&source=SITE_NAME',
		newsvine:'http://www.newsvine.com/_tools/seed&save?u=PERMALINK&h=TITLE',
		devmarks:'http://devmarks.com/index.php?posttext=DESC&posturl=PERMALINK&posttitle=TITLE',
		google:'http://www.google.com/bookmarks/mark?op=add&bkmk=PERMALINK&title=TITLE&labels=&annotation=',
		misterwong:'http://www.mister-wong.com/addurl/?bm_url=PERMALINK&bm_description=TITLE&plugin=',
		friendfeed:'http://www.friendfeed.com/share?title=TITLE&link=PERMALINK',
		blogmarks:'http://blogmarks.net/my/new.php?mini=1&simple=1&url=PERMALINK&title=TITLE',
		yahoo:'http://myweb2.search.yahoo.com/myresults/bookmarklet?t=TITLE&d=DESC&tag=&u=PERMALINK',
		livefavorites:'http://favorites.live.com/quickAdd.DTpx?url=PERMALINK&title=TITLE&text=DESC',
		pixelgroovy:'http://www.pixelgroovy.com/submit.php?url=PERMALINK',
		simpy:'http://www.simpy.com/simpy/LinkAdd.do?title=TITLE&tags=&note=DESC&href=PERMALINK',
		propeller:'http://www.propeller.com/submit/?U=PERMALINK&T=TITLE',
		yigg:'http://yigg.de/neu?exturl=PERMALINK',
		linkarena:'http://linkarena.com/bookmarks/addlink/?url=PERMALINK&title=TITLE&desc=DESC&tags=',
		hatena:'http://b.hatena.ne.jp/add?url=PERMALINK'
	},
	gotoShare:function(name){
		var url=this.checkUrl(this.urlList[name]);
		window.open(url,"sharing","",true);
	},
	checkUrl:function(url){
		var href=encodeURIComponent(top.location.href);
		var desc=this.desc();
		var title=encodeURIComponent(top.document.title);
		var twitterText=this.twitterText();
		var re=[/PERMALINK/,/DESC/,/TITLE/,/TWITTER_TEXT/];
		var to=[href,desc,title,twitterText];
		for(var i=0;i<re.length;i++){
			url=url.replace(re[i],to[i]);
		}
		return url;
	},
	twitterText:function(){
		var title=top.document.title;
		var href=top.location.href;
		var hrefLen=href.length+4;
		var text=title+"+at+"+href;
		if(title+hrefLen>140){
			var t=title.substring(0,140+hrefLen);
			var dot=t.lDTtIndexOf(".");
			var space=t.lDTtIndexOf(" ");
			if(dot>-1){
				t=t.substring(0,dot);
			}
			else if(space>-1){
				t=t.substring(0,space);
			}
			text=t+"+at+"+href;
		}
		text=text.replace(/\s/g,"+");
		return text;
	},
	desc:function(){
		var desc="";
		var head=top.document.getElementsByTagName("head")[0];
		var metDT=head.getElementsByTagName("meta");
		for(var i=0;i<metDT.length;i++){
			if(metDT[i].name){
				if(metDT[i].name.toLowerCDTe()=="description"){
					desc=metDT[i].content;
					break;
				}
			}
		}
		return encodeURIComponent(desc);
	},
	gotoSharingList:function(n){
		var panel=$('sharePanel'+n);
		if(panel&&panel.style.visibility=='hidden'){
			var text="<table cellpadding=\"4\" cellspacing=\"0\" align=\"center\"><tr>";
			for(var x=0;x<this.list.length;x++){
				text+="<td><a href=\"javDTcript:DT.share.gotoShare('"+this.list[x]+"');\"><img src=\"images/share/"+this.list[x]+".gif\" width=\"16\" height=\"16\" border=\"0\"></a></td>";
			}
			text+="</tr></table>";
			panel.innerHTML=text;
			panel.style.position='';
			panel.style.visibility='visible';
		}
		else{
			panel.style.position='absolute';
			panel.style.visibility='hidden';
		}
	}
};
sur ma page (dynamique) à partager j'ai comme code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
		<div id=\"sharePanel2\" style=\"align:center; margin:2px;border:gray 1px solid;background-color:#f0f0f0;text-align:center;visibility:hidden;position:absolute;top:2px;left:2px\">
</div>
et
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
						<td class=\"msHP2\"><a href=\"javascript:DT.share.gotoSharingList(2);\"><img src=\"images/share/share.gif\" border=\"0\"></a></td>
				<td class=\"msHP2\"><a href=\"javascript:DT.share.gotoShare('google');\"><img src=\"images/share/google2.gif\" border=\"0\"></a></td>
				<td class=\"msHP2\"><a href=\"javascript:DT.share.gotoShare('yahoo');\"><img src=\"images/share/yahoo2.gif\" border=\"0\"></a></td>
				<td class=\"msHP2\"><a href=\"javascript:DT.share.gotoShare('twitter');\"><img src=\"images/share/twitter2.gif\" border=\"0\"></a></td>
				<td class=\"msHP2\"><a href=\"javascript:DT.share.gotoShare('facebook');\"><img src=\"images/share/facebook2.gif\" border=\"0\"></a></td>
Cependant aucune fenetre ne s'ouvre
est ce que j'ai manqué quelque chose ? merci de repondre