简体   繁体   中英

Is there any way in which on click of link/anchor tag it will redirect to some part of page/image in Word add-ins using office-js

open link for Demo image

const [tableRow, setTableRow] = useState([["ID", "Image URL", "Photographer"]])

const insertTable = async (response) => {

Word.run(async (context) => {
  const photographer = response.photographer;
  const img_id = response.id;
  const img_url = response.url;
  const arr = [img_id, img_url, photographer]

  table_array = [...tableRow, arr]    
  setTableRow(table_array)    
  const row_length = table_array.length;
  const body = context.document.body

   body.clear()
  //insert Table
  body.insertTable(row_length, 3, "End", table_array);
  await context.sync();
})
  .catch(function (error) {

    console.log("Error: " + error);

    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

}

yes, you can do this by adding hyperlinks to a location within the same document. please see here for details: https://support.microsoft.com/en-us/office/add-hyperlinks-to-a-location-within-the-same-document-1f24fc4f-7ccd-4c5f-87e1-9ddefb672e0e

And this kind of hyperlink is fully supported by word JavaScript API, such as range.hyperlink = "#Bookmark1";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM