0

Per this suggestion from a Microsoft employee, I tested that the following code in Home.js file successfully opens a URL (html page) in a default browser if URL is defined. But if url is left blank, it gives following message by my Windows 10 desktop. I was expecting it to instead display a default about:blank page as demonstrated in this W3schools.com online tutorial page.

Following two work in Home.js:

window.open('https://www.google.com/','test title');
or
window.open('http://localhost/myWordWebAddIn1Project/SomeHtmlFile.html','test title');

But following in Home.js instead displays the regular Windows 10 message (shown below) asking you to choose an app/program to open the following page:

 window.open('','test title');

Message that popups up by Windows 10 when you use the above line in your add-in:

enter image description here

Question: How can we make the window.open('','test title'); work in the add-in as well?

NOTE: Please note again, the above line of code works fine in W3Schools online tutorial linked above.

nam
  • 21,967
  • 37
  • 158
  • 332
  • Why wouldn't you set URL to `about:blank` instead of passing empty string and try? And another more important question: why do you want your user to see empty page at all? – Slava Ivanov Oct 22 '18 at 16:54
  • @SlavaIvanov Your second question is more important. I intend to write data to the page using 1. `var myWindow = window.open('','test title');` and then 2. `myWindow.document.write(…);` But first `1` needs to work before I can get `2` to work. Or, let me know if there is a better way of doing it. Goal is 1. Get html from WORD document 2. Using `jQuery`, reformat that html based on some business needs 3. Dynamically display that reformatted HTML on default browser of Windows desktop. All this needs to be done via `Office.js` add-in for `word`. – nam Oct 22 '18 at 18:06
  • 1
    Did you try to use `about:blank` URL? Also you may try to use `/` as URL, not sure what is going to be resolve to under desktop Word. – Slava Ivanov Oct 22 '18 at 18:16
  • @SlavaIvanov Your first suggestion (using `about:blank`) worked (thank you). `/` gave the error `HTTP Error 403.14 - Forbidden`. Amazing, did not know `about:blank` is a URL. But, thanks to you, now I know. – nam Oct 22 '18 at 19:05
  • `about:` is yet another protocol. Glad it worked out. Best regards. – Slava Ivanov Oct 22 '18 at 19:39
  • @SlavaIvanov Now I want to use `displayDialogAsync(…)` to open a URL. But this requires a separate post - so, I posted it [here](https://stackoverflow.com/q/52937467/1232087) – nam Oct 22 '18 at 20:46

0 Answers0