Hi!
I’m making a digital library for a school project. I’m using a database and a dynamic page to show all the data, as expected. The only problem comes when I’m trying to show the PDF file through Google Drive.
Until yesterday I think, everything worked perfectly. But then I added some things to be able to embed a video of the story, and the PDF viewer stopped showing the file. I opened the console log and it gave the message " Wix code SDK error: The url parameter that is passed to the src method cannot be set to the value . It must be of type url. "
Everything is embed through an HTML/iFrame component, and I don’t get why it stopped working. I debugged through the console log every step and it threw ‘undefined’ when I add all the parts of the url.
Here is the code
let source;
if ( datos.archivoPDF === undefined || datos.archivoPDF === "" || datos.spreakerEmbebido === "http://" || datos.spreakerEmbebido === "https://" ) {
$w('#cuento').hide();
$w('#columnaVideo').hide();
} else {
$w('#cuento').show();
$w('#videoDos').hide();
$w('#videoDosTXT').hide();
let documento = datos.archivoPdf;
code = documento.split("/").slice(0)[5];
source = "https:// docs. google. com/viewer?srcid=" + code + "&pid=explorer&efh=false&a=v&chrome=false&embedded=true";
console.log(source);
$w('#cuento').src = datos.archivoPdf;
}
(The links are spaced to be able to post this) And in case you’re wondering, “#cuento” is the html component for the PDF, “#columnaVideo” is a strip with a youtube video and “#videoDos” is the same video but shows in case that there’s no PDF.
The idea is to be able just to copy the url on the database table and the program should turn it into an embed Google Drive url (this must be done by professors and young students so I didn’t want to make it very complex).
Hope this doesn’t bother anyone and,of course, thanks in advance.
EDIT: Ok I’m a very distracted person but somehow I realized that it was just a typo. But in case someone’s happening the same, I found that the mistake is in the if statement:
if ( datos.archivoPDF === undefined || datos.archivoPDF === "" || datos.spreakerEmbebido === "http://" || datos.spreakerEmbebido === "https://" )
Where it says “datos.archivoPDF” it should be “datos.archivoPdf”. Also the “spreakerEmbebido” should be “archivoPdf”, so the final code should be:
if ( datos.archivoPdf === undefined || datos.archivoPdf === "" || datos.archivoPdf === "http://" || datos.archivoPdf === "https://" )
Hope this helps someone, cheers.