Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > JavaScript
JavaScript Forum programmation JavaScript. Lire : Cours JavaScript, FAQ JavaScript, Toutes les FAQ JavaScript et Sources JavaScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 25/01/2011, 23h59   #1
Nouveau Membre du Club
 
Inscription : juin 2010
Messages : 116
Détails du profil
Informations forums :
Inscription : juin 2010
Messages : 116
Points : 28
Points : 28
Par défaut Programme de partage en javascript non fonctionnel

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 :
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 :
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 :
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
AyManoVic est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/01/2011, 10h29   #2
Modérateur
 
Avatar de NoSmoking
 
Homme
Inscription : janvier 2011
Messages : 2 930
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France, Isère (Rhône Alpes)

Informations forums :
Inscription : janvier 2011
Messages : 2 930
Points : 4 744
Points : 4 744
Citation:
Cependant aucune fenetre ne s'ouvre
est ce que j'ai manqué quelque chose ? merci de repondre
OUI probléme dans le javascript...
à remplacer au bas mot par
Code :
1
2
3
if(!DT){
  var DT={}; // petit detail qui compte je parle de var bien sur !
}
NoSmoking est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/01/2011, 13h17   #3
Nouveau Membre du Club
 
Inscription : juin 2010
Messages : 116
Détails du profil
Informations forums :
Inscription : juin 2010
Messages : 116
Points : 28
Points : 28
Non je ne pense pas , car le fichier share.js qui contient ce programme est appelé dans ma page php
cette page php qui fait appel à un fichier ajax qui definit DT
d'ailleurs j'ai essayé ta propo mais ça marche toujours pas
AyManoVic est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/01/2011, 15h29   #4
Modérateur
 
Avatar de NoSmoking
 
Homme
Inscription : janvier 2011
Messages : 2 930
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France, Isère (Rhône Alpes)

Informations forums :
Inscription : janvier 2011
Messages : 2 930
Points : 4 744
Points : 4 744
tout d'abord ne mets pas en Résolu si ce n'est pas le cas.

Hors du contexte il va être difficile de trouvé, mais quelque chose d'autre n'intrigue
Code :
<td class=\"msHP2\"><a href=\"javascript:DT.share.gotoShare('google');\"><img src=\"images/share/google2.gif\" border=\"0\"></a></td>
devrait plutôt apparaître dans ton document comme
Code :
<td class="msHP2"><a href="javascript:DT.sh9;"><img src="images/share/google2.gif" border="0"></a></td>
sans les \ devant les",il n'est qu'à regarder la coloration syntaxique...
NoSmoking est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 03h18.


 
 
 
 
Partenaires

Hébergement Web