Implicit references etc.

Workarounds and usability notes.

Implicit references etc.

Postby John Robin Dove » Sat Nov 11, 2023 12:28 pm

Hi Clifton.

I'm still bashing away at what I hope will be the final version of my project. I am trying to tidy up the code and looking for any remaining bugs. There can't be many left... but I've said that many times before. Today I have found solutions to a couple of problems. Perhaps you could explain why they occurred, if you have time, please?

1) In my code I use references to files and folders such as this: filesHome = "../../" + this.VArray [2] + "/" + this.VArray [5] + "/teachers/" + this.VArray [7] + "/" + this.VArray [6] + "/" + this.VArray [3] + "/";

Alternatively I sometimes use: filesHome = "/programs/" + this.VArray [2] + "/" + this.VArray [5] + "/teachers/" + this.VArray [7] + "/" + this.VArray [6] + "/" + this.VArray [3] + "/";

I decided to 'tidy things up' by using only one system. I replaced all occurrences of "/programs/" with "../../" Days later I discovered that a certain function would no longer work in Firefox and Edge but there was no problem in Chrome. The function was for downloading. I use pgExecuteRemote to execute a function in an embedded html file like this:

<a style="visibility: hidden" id="dl" href="" download></a>
function downloadFile(fileName)
{
document.getElementById("dl").href = fileName;
document.getElementById("dl").click();
};


After days of searching, I discovered that if I use "../../" etc in the fileName variable, it doesn't work (in Firefox and Edge) but if I replace this with "/programs/", it does. Should I now replace all occurrences of "../../" with "/programs/" to be on the safe side? What do you think?

2) The other problem is simpler. I was trying to create a private cookie with createCookie(). If I name the cookie "docs" it fails but if I name it "mdc_docs", all goes well. Is "docs" a reserved name or is it too short?

3) It seems that Microsoft may have addressed the problem of wrong analysis of files in Windows 11. I mean innocent files being flagged up as viruses. When I installed the latest version of Powerpac on Windows 11, I had the option to ignore the warning. That doesn't happen on Windows 10 and I now have to stop Windows Defender before I can install.

John
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Implicit references etc.

Postby Clifton » Sat Nov 11, 2023 7:01 pm

I think your program is getting confused as to where it is when you use "../../".
In addition, if you want to end up in /programs/, you should try "../../programs/" to get there.
You can also try replacing "../../" with "https://mysite.com/programs/".

It is my guess that the reason why Chrome works when Firefox and Edge do not is that it may be that "../../" is actually transporting you beyond the public area of your site and Firefox and Edge cannot find the /program/ in that area. Chrome on the otherhand "may" be disallowing access beyond the public area no matter how many relative paths you use.

Here is an example of using relative paths:
[www]
[myApp] (ToolBook export is here for example)
[media]
[cm]
index.html (starts your program)
[programs]
somefile.dat

In the above scenario, you assume that all paths for your program start in [cm] and relative ones back up from there.
So to access the "[media]/somepic.jpg" you would use "../media/somepic.jpg".

To access "[programs]/somfile.dat" you would use "../../programs/somfile.dat".

Hopefully this helps a bit.
Clifton
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Implicit references etc.

Postby John Robin Dove » Mon Nov 13, 2023 5:40 am

Many thanks.
John
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron