Un saluto grande a tutto il Forum.
Ho bisogno dell'aiuto di qualche esperto di javascript su pdf.
In pratica sto inserendo un popup con web form di registrazione all'apertura del pdf, cioè per leggerlo bisogna inserire i proprio dati altrimenti si deve chiudere il pdf.
Però non riesco a impostare il pulsante di chiusura, se clicco su chiudi il pdf, mi chiude solo la finestra popup, ma non è quello che voglio, deve chiudere il pdf se non inseriscono i dati, non permettendo di leggerlo, (d'altronde è gratuito javascript:void(0).
Inserisco qua in basso il codice:
//<Document-Actions>
//<ACRO_source>Documento aperto</ACRO_source>
//<ACRO_script>
/*********** appartiene a: Document-Actionsocumento aperto ***********/
var dialog1 = {
commit:function (dialog)// called when OK pressed
{
var results = dialog.store();
name = new String(results["fnam"]);
while (name.indexOf(" ") != -1)
name = name.replace(" " , "+");
mylink = new String("http://www.aweber.com/scripts/addlead.pl?name=#name#&from=#email#&unit=xxxxxxxxx xxxxxx&redirect=http%3A%2F%2Fwww.xxxxxxxx.xxx%2Fxx xxxxx.xxxx");
mylink = mylink.replace("#name#", name);
mylink = mylink.replace("#email#", results["mail"]);
app.launchURL(mylink, true);
},
validate:function(dialog)
{
var results = dialog.store();
var objRegExp =/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/;
var TestName =/^[s]*$/;
if (results["fnam"] == "" || results["fnam"] == " " || results["fnam"] == " " || results["fnam"] == " ")
{
app.alert({
cMsg: "Please enter your name",
cTitle: "Error! Try again!",
nIcon: 0
});
return false;
}
if (!(objRegExp.test(results["mail"])))
{
app.alert({
cMsg: "Please enter a valid email address",
cTitle: "Error! Try again!",
nIcon: 0
});
return false;
}
else
return true;
},
initialize: function (dialog) {
dialog.load({tttt: "Inserisci il tuo Nome e indirizzo Email e clicca su 'LEGGI IL REPORT'\nper poter leggere il mio Special Report Pdf\n"});
dialog.load({cspa: "Noi rispettiamo la tua Privacy in base alle vigenti normative.\n"});
},
description:
{
name: "Subscribe", // dialog title
align_children: "align_left",
//width: 350,
//height: 200,
elements:
[
{
type: "static_text",
char_height: 4,
alignment: "align_center",
font: "dialog",
bold: true,
char_width: 60,
item_id: "tttt",
},
{
type: "cluster",
name: "",
elements:
[
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "Nome: ",
alignment: "align_left",
char_width: 15
},
{
item_id: "fnam",
type: "edit_text",
alignment: "align_fill",
char_width: 30,
height: 20
},
]
},
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "Email: ",
char_width: 15
},
{
item_id: "mail",
type: "edit_text",
alignment: "align_fill",
char_width: 30,
height: 20
}
]
},
{
type: "static_text",
char_height: 2,
char_width: 60,
alignment: "align_center",
font: "default",
item_id: "cspa",
},
]
},
{
alignment: "align_right",
type: "ok_cancel",
ok_name: "LEGGI IL REPORT",
cancel_name: "CHIUDI IL PDF"
},
]
}
};
if ( app.viewerVersion >= 7 )
{
app.beep(2);
app.execDialog(dialog1);
}
//</ACRO_script>
//</Document-Actions>
//<Document-Actions>
//<ACRO_source>Il documento sarà chiuso</ACRO_source>
//<ACRO_script>
/*********** appartiene a: Document-Actions:Il documento sarà chiuso ***********/
var a = 1
//</ACRO_script>
//</Document-Actions>
Vi prego aiutatemi ci son 3 giorni e non ne vengo a capo!