Click to See Complete Forum and Search --> : loading a pdf file with a button


tlavalle
08-06-2003, 09:31 AM
I need some help here I have been trying to use a js button to load a pdf but for some reason I just don't have it right can someone help here.

here is the code i am using:

<html>
<head>
<title>monthly specials</title>
</head>


<body>
<div align="center">
<script language="JavaScript">
function goToUrl(){
window.location = "http://Template/documents/salesflier.pdf"; }
</script>
</div>
<p align="center"><font size="4" face="Arial, Helvetica, sans-serif"> To View
the online specials click on the link below </font></p>
<p align="center"><font size="4" face="Arial, Helvetica, sans-serif">You do need
Adobe Acrobat Reader </font></p>
<p align="center">If you need Adobe Reader you may download it here for free from
<a href="http://www.adobe.com/products/acrobat/readstep2.html">Adobe</a>.</p>
<form action="/Template/documents/salesflier.pdf">
<div align="center">
<input name="button" type="button" onClick="goToUrl()" value="Sales Flier">
</div>
</form>


</div>
</body>
</html>

I just need a little help trying to figure out how to get a js button to load the pdf.:D

cacalex
08-06-2003, 10:57 AM
I see nothing wrong to your code,

But maybe you should try to replace
window.location = "http://Template/documents/salesflier.pdf"; }

by
window.location = "/Template/documents/salesflier.pdf"; }

tlavalle
08-06-2003, 11:05 AM
ok that seemed to work alittle better, since now once the button is pushed nothing happens. see the pdf is stored on the server and when people click on the link they got this page I originally had the pdf load from a link, bu now I am trying to clean up the page.:D

pyro
08-06-2003, 11:07 AM
Originally posted by tlavalle
see the pdf is stored on the server and when people click on the link they got this page I originally had the pdf load from a link, bu now I am trying to clean up the page.:D Do yourself a favor and go back to the old method. Using a regular link will keep the PDF working for those without javascript enabled.

cacalex
08-06-2003, 11:10 AM
Hey pyro !
Thanks for the comments,
Since i'm a little bite selfish, i always forget those without javascript enabled. ;)

Your right !

pyro
08-06-2003, 11:15 AM
Yes, we must remember to keep our pages accessable. 13% of web users browse the internet with javascript disabled, be it due to choice or a disablility that does not allow them to use javascript. Javascript is a great tool for adding non essential items to your page, but is not meant to control items such as navigation, etc, unless you have some sort of backup plan.

tlavalle
08-06-2003, 11:28 AM
I guess i just want to do things the hard way.:D

I can leave it that but there seems to me it would look better with a button.

but thanks for the help

pyro
08-06-2003, 11:36 AM
If you want to use a button, this would be the accessable way of doing it:

<form action="http://www.w3c.org" method="post">
<p><input type="submit" value="Load Page"></p>
</form>

tlavalle
08-06-2003, 11:52 AM
Hmm I tried, but I must have entered it wrong. but I will leav as a link.