Using td onclick= to view local pdf file

I am new to JavaScript so bear with me....

How can I use "td onclick=" to open a local file (am specifically looking to open/view a pdf in my webbroswer)

Who is Participating?
Open PDF that is local to web server or your computer? Or are you trying to package the webpage and PDF into a CD that launches web browser, etc.?

If not running from CD or web server, I fail to see why you want to open a PDF in web browser. If you want to do so on local computer as some type of application, you might want to make the HTML webpage into a Microsoft HTA application, which is a client side HTML webpage that allows you to use VBScript and javascript and provides extra features that are blocked from standard HTML due to security restrictions.

And it is usually better to attach an onclick to an image, button, or link, not a table cell. If you want to load a PDF into web browser from a webpage, you could use frames or launch a new web browser window and have the link target attribute set to the name of the frame or new window. <a href="..." target="_blank"> will automatically load the link in a new window. And if the web browser has PDF plugin installed correctly, if you just have simple link like <a href="my.pdf">, it will load the PDF in the same browser window replacing your current page.
it really depends what you are trying to do...

start with this:

<td onclick="'pathToPdf.pdf');">
scbdpmAuthor Commented:
I would like to open the PDF in a webbrowser control/window in VB....
b0lsc0ttIT ManagerCommented:
If the file is on the computer with the browser then you can't.  Browser security should stop this.  There are exceptions (e.g. the page is local, on an intranet, or a few, bad browsers) but in general the browser won't let javascript (or any script) access the computer.  The example the expert provided above would try to open pathToPdf.pdf in the same folder as the webpage file.

Let me know if you have a question or need more info.

b0lsc0ttIT ManagerCommented:
I'm glad I could help.  Thanks for the grade, the points and the fun question.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.