- window.open ("/www/puinap/htdocs/profoundui/userdata/docs/2012 AC Enrollment Form.pdf")
Profound returns a message that the document cannot be found.
I and one other person have verified that the path is correct.
Another developer used a HTML Container instead of a hyperlink but gets the same results.
Do we have the document's location correct in the root directory?
Java Script is not working
-
- Profound User
- Posts: 35
- Joined: Thu Mar 15, 2012 3:42 pm
- First Name: Robert
- Last Name: Moore
- Company Name: General Parts Company
- Phone: 770-818-4736
- Address 1: 3100 Windy Hill Rd.
- City: Atlanta
- State / Province: Georgia
- Zip / Postal Code: 30339
- Country: United States
- Contact:
Java Script is not working
I have a hyperlink defined to retrieve a PDF document. The Onclick event is defined with the following JavaScript
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Java Script is not working
The path passed to "window.open()" is not correct. Note that this is a built-in function of the browser that has nothing to do with PUI.
The trouble is that the HTTP server document root directory (/www/puinap/htdocs, in this case) is given in the path. The HTTP server assumes all paths start at the document root directory, so with the code below it's looking for the file here:
/www/puinap/htdocs/www/puinap/htdocs/profoundui/userdata/docs/2012 AC Enrollment Form.pdf
The document root directory should never be given in the path. Use this instead:
/profoundui/userdata/docs/2012 AC Enrollment Form.pdf
This will locate the file correctly, because all links on your server are assumed to be within /www/puinap/htdocs.
The trouble is that the HTTP server document root directory (/www/puinap/htdocs, in this case) is given in the path. The HTTP server assumes all paths start at the document root directory, so with the code below it's looking for the file here:
/www/puinap/htdocs/www/puinap/htdocs/profoundui/userdata/docs/2012 AC Enrollment Form.pdf
The document root directory should never be given in the path. Use this instead:
/profoundui/userdata/docs/2012 AC Enrollment Form.pdf
This will locate the file correctly, because all links on your server are assumed to be within /www/puinap/htdocs.
- Brian
- Profound Logic Staff Member
- Posts: 286
- Joined: Thu Apr 14, 2011 10:23 am
- First Name: Brian
- Last Name: May
- Company Name: Profound Logic Software
- Contact:
Re: Java Script is not working
Remember, Javascript runs in the browser, not on the server. Whatever you pass to window.open should be something that would work if typed in the browsers address bar.
Judging by the folder you passed, I would guess that you would want
window.open ("http://yourserver:8080/profoundui/userdata/docs/2012 AC Enrollment Form.pdf")
Judging by the folder you passed, I would guess that you would want
window.open ("http://yourserver:8080/profoundui/userdata/docs/2012 AC Enrollment Form.pdf")
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Java Script is not working
Brian's example would be good for linking to a document on an external HTTP server. Mine is what should be used if linking to a document on the same HTTP server, which is what you are attempting in this case.
-
- Profound User
- Posts: 35
- Joined: Thu Mar 15, 2012 3:42 pm
- First Name: Robert
- Last Name: Moore
- Company Name: General Parts Company
- Phone: 770-818-4736
- Address 1: 3100 Windy Hill Rd.
- City: Atlanta
- State / Province: Georgia
- Zip / Postal Code: 30339
- Country: United States
- Contact:
Re: Java Script is not working
Thank-you, gentlemen. David's syntax worked in the development environment, but I am uncertain whether or not we shall have to use Brian's syntax when we roll out to production. Your assistance has proved invaluable. I shall publish both situations to the entire team.
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Java Script is not working
Using Brian's will hard code the HTTP server that the document is fetched from. Where mine will look for the document on the "current" HTTP server.
So it depends on what you want.
I think the latter is what you'd actually want -- just make sure the document exists in both places.
So it depends on what you want.
I think the latter is what you'd actually want -- just make sure the document exists in both places.
-
- Profound User
- Posts: 35
- Joined: Thu Mar 15, 2012 3:42 pm
- First Name: Robert
- Last Name: Moore
- Company Name: General Parts Company
- Phone: 770-818-4736
- Address 1: 3100 Windy Hill Rd.
- City: Atlanta
- State / Province: Georgia
- Zip / Postal Code: 30339
- Country: United States
- Contact:
Re: Java Script is not working
True. But DNS should help us with the server. I have been in situations when a server was swapped out or repurposed. In those cases, it was often easier to make sure the new server used the same name but a different TCP/IP address.
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Java Script is not working
But here your document is on the same http server as the page you're linking from.
In this case, you would usually never want to specify the server or port. It is unnecessary and will cause you some problems.
Doing that means that when you run the same page under another HTTP server (such as the multiples you guys have setup between your different environments), the link will be hard-coded to point back to your development environment HTTP server, rather than just looking for the document on the same HTTP server as the page is running on.
What you'll want to do is use the link which does not reference the server name or port and make sure the doc is in the same place on all HTTP servers. Then you can run the page anywhere and the link works. This also allows you to make modifications to the document in development without affecting live users.
In web development, usually the only time you'll use a fully qualified URL is when you are linking to "somebody else's" HTTP server. Like bringing up a Google program or another application within your organization.
In this case, you would usually never want to specify the server or port. It is unnecessary and will cause you some problems.
Doing that means that when you run the same page under another HTTP server (such as the multiples you guys have setup between your different environments), the link will be hard-coded to point back to your development environment HTTP server, rather than just looking for the document on the same HTTP server as the page is running on.
What you'll want to do is use the link which does not reference the server name or port and make sure the doc is in the same place on all HTTP servers. Then you can run the page anywhere and the link works. This also allows you to make modifications to the document in development without affecting live users.
In web development, usually the only time you'll use a fully qualified URL is when you are linking to "somebody else's" HTTP server. Like bringing up a Google program or another application within your organization.
Who is online
Users browsing this forum: No registered users and 2 guests