Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4603240
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:06:58+00:00 2026-05-22T00:06:58+00:00

I got a PDF embedded in my page, and I’d like to set something

  • 0

I got a PDF embedded in my page, and I’d like to set something like a Javascript-callback to be called whenever the user clicks a link within the PDF.

Is there a way to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:06:59+00:00Added an answer on May 22, 2026 at 12:06 am

    If you check out the Acrobat JS Reference for the minimum version you want to support, you’ll see documentation on the HostContainer object.

    In the PDF:

    this.hostContainer.messageHandler =
    {
      onMessage: function(messageArray)
      {
        for(var i = 0; i < messageArray.length; i++)
          console.println("Message " + i + ": " + messageArray[i]);
      },
      onError: function(error, messageArray){ },
      onDisclose: function() {return true;}
    };
    

    In your HTML, assuming your PDF is inside an <object id="thePdf"> tag:

    function messageFunc(messageArray) {
        for(var i = 0; i < messageArray.length; i++)
          alert("Message " + i + ": " + messageArray[i]);
    }
    
    document.getElementById("thePdf").messageHandler = { onMessage: messageFunc };
    

    In your PDF, you’d also need to modify the links so they have a JS action that would post a message to the containing web page. This could be done programmatically (varying wildly depending on the language/library you use), or manually in Acrobat Pro.

    this.hostContainer.postMessage(["urlClicked", "http://blah.blah.blah..."]);
    

    Not terribly hard, but no one’s ever heard of it. I’d be stunned if this worked anywhere outside an Adobe viewer (Reader/Acrobat) for the next several years.

    If you want to send a message from your HTML to the PDF for some reason, it goes something like this:

    var thePDF = document.getElementById("thePdf");
    thePDF.postMessage(["This", "is", "an", "array", "too."]);
    

    You could even yank out all the existing links and have the PDF request the links be opened by the wrapping HTML page… that way you can give the new windows names, close them from JS, etc. You can get down right snazzy.

    But you have to be able to change the PDFs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this page called pdf.php: <?php $im = new imagick( 'uploadedfiles/logo.pdf[0]' ); $im->setImageFormat(
I am exporting data table from php page to pdf I got the page
I've got a controller action that returns a FileResult like this return this.File(file.pdf, application/pdf);
I've got a PDF I'd like to show in a Book Control . Since
I've got a C# page that's generating a PDF file and returning it to
I've got a web page with a link, and the link is suppose to
(related to my previous questiuon) i've got 100s of fileswith names like: CPC_2001_5_21_7.pdf CPC_YYYY_M_DD_X.pdf
I got a pdf creator on my webapp where my user can create a
This question on archiving PDF's got me wondering -- if I wanted to compress
I've got a strange problem with indexing PDF files in SQL Server 2005, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.