abracadabraPDF › Forums › PDF – Général › Action pour ouvrir une page web par script › Répondre à : Action pour ouvrir une page web par script

bonjour,
Voici ma proposition qui devrait correspondre à ce que tu demandes :
var i=event.target.name.substr(6);
var j=this.getField("NoLieT."+i).value;
if (this.getField("LinkT."+i+"."+j).buttonGetCaption()!="....") {
app.alert("Ce bouton renvoie déjà à une url.",3);
} else {
var leLien=this.getField("LaT."+i).value;
if (j!="-" && /^(https?:\/\/)?([\w-]+(\.[\w-]+)+)(:\d+)?(\/[^\s]*)?$/i.test(leLien)) {
this.getField("LinkT."+i+"."+j).setAction("MouseUp","app.launchURL(\""+leLien+"\");");
var texteBouton="";
while ((!/^(\w|\W)+( (\w|\W)+)*$/.test(texteBouton) && texteBouton!=null) || texteBouton=="Exemple") {
var texteBouton=app.response({
cQuestion: "Quel nom souhaitez-vous attribuer à ce bouton ?",
cTitle: "Nom du bouton",
cLabel: "Nom :",
cDefault: "Exemple"
});
}
if (texteBouton!=null) {
this.getField("LinkT."+i+"."+j).buttonSetCaption(texteBouton);;
this.getField("LinkT."+i+"."+j).fillColor=color.green;
this.getField("LaT."+i).value="";
for (var k=0; k<10; k++) {
if (this.getField("LinkT."+i+"."+k).buttonGetCaption()=="....") {
this.getField("NoLieT."+i).value=k;
break;
}
}
if (k==10) app.alert("Tous les boutons renvoient à une url",3);
}
}
else if (j=="-") app.alert("Veuillez choisir un numéro d'indice",3);
else app.alert("L'url indiquée n'est pas correcte",3);
}
@+
😎