...

View Full Version : JS & Acrobat Problem



ccemmett
01-09-2007, 12:25 AM
We have a catalog of the products we sell online as a collection of PDF files. The files may be accessed individually or there is the option of going directly to any catalog page by using a little js utility.

The utility is your typical input text box & button combo. Typing in a valid page number in the text box and clicking the button opens a new window with a PDF turned to the requested page, and works on the most common browsers/ OS combinations.

Here's the prob: We decided to make it so the ENTER key would activate the script. Works fine in Windows, but on Mac with Safari nada! What these users get is the correct PDF turned to page one. I've tried a few variations of the key capture code to no avail.
:confused: At present I am clueless though my intuition suggests this may have something to do with Acrobat.

Thoughts? Thanks! -cc

Key capture snippet-


function getKey(e){
var unicode=e.keyCode? e.keyCode : e.charCode
if(unicode==13){
document.getElementById('fetchit').click()
}
}

Links-

Complete JS code (http://macmurraypacific.com/ctest.js)

Catalog Page (http://macmurraypacific.com/ctest.html)

A1ien51
01-09-2007, 05:30 AM
function handleKeyPress(evt) {
var keyCode = (window.event)?event.keyCode:evt.which;
alert(keyCode);
return true;
}
document.onkeydown= handleKeyPress

Eric

ccemmett
01-12-2007, 03:04 PM
Thanks for your reply. Sorry to be late getting back to you but I can only work on this once a week. In any case am trying your code with a little variation, thus:


function handleKeyPress(evt) {
var keyCode = (window.event)?event.keyCode:evt.which;
if(keyCode==13){
document.getElementById('fetchit').click()
}
}
document.onkeydown= handleKeyPress

We tried your solution, but I'm afraid it did not work. Seems this is a stickier prob than it seemed.
CC

txaggie00
01-12-2007, 06:43 PM
function handleKeyPress(evt) {
var keyCode = (window.event)?event.keyCode:evt.which;
if(keyCode==13){
document.getElementById('fetchit').click()
}
}
document.onkeydown= handleKeyPress

what if you called your onClick function if keyCode==13?
if(keyCode==13){
pageFetch();
}

ccemmett
01-12-2007, 06:50 PM
Afraid that's the original version that didn't work many versions ago.
Hmmm, maybe I ought to post this on an Acrobat board.

CC

txaggie00
01-12-2007, 06:58 PM
I am sorry, you would probably need to pass the the "page number" to your pageFetch() function.

name your form something ie pageForm and your text input box name; ie pageInput

pageFetch(document.pageForm.pageInput.value)

your pnum variable in pageFetch can be set to the value you pass it.

txaggie00
01-12-2007, 07:22 PM
I just read through your code a bit.

Shouldn't your donKeyDown be onKeyDown?

ccemmett
01-13-2007, 05:46 PM
The pageFetch() function automatically snatches the text and because the code uses the event listener document.onkeydown= handleKeyPress to detect the keydown event I disabled the keydown event in the input box.

Thanks for you help btw. I have an idea I'm going to try this weekend. Trouble is I don't have a Mac so I can't test the code directly. More soon.:D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum