Jump to content

How to view a PDF file in a new browser tab?


jrp

Recommended Posts

7 hours ago, jrp said:

I mean: I have the URL of a PDF file. When a button clicked, I want to display that URL in a new browser tab (not a new browser window).

UniSession.AddJS('var myWindow = window.open(''' + YourFullPathToFile_FileName {OR URL} + ''', ''foo'','''');'//+ ''', ''_blank'');'
                                        + ' if (myWindow == null)'
                                        + '   alert (''Please change your popup settings'');'
                                        + ' else  {'
                                        + '  myWindow.moveTo(0, 0);'
                                        + '  myWindow.resizeTo(screen.width, screen.height);'
                                        + '}'
                                    //+ 'myWindow.print();'
                                    //+ 'myWindow.close();'
                                    );

  • Like 1
Link to comment
Share on other sites

Hello irigsoft,

It took me some time to understand your code, but finally I made it 😁

This is the actual code I use:

UniSession.AddJS('var myWindow = window.open(''' +FileURL+ ''', ''_blank'');'
  + ' if (myWindow == null)'
  + '   alert (''Please change your popup settings'');'
  + ' else  {'
  + '  myWindow.moveTo(0, 0);'
  + '  myWindow.resizeTo(screen.width, screen.height);'
  + '}');

Thank you irigsoft. I don't know JavaScript at all.

I think this should be considered a basic functionality, and should be provided by UniGUI, so we don't need to touch any JavaScript. Maybe we should have something like UniSession.OpenUrl(AUrl: string; NewTab: boolean);

  • Like 2
Link to comment
Share on other sites

1 hour ago, jrp said:

I think this should be considered a basic functionality,

Thank You,

In the beginning I needed help too - and I still don't know javascript, but here is a programming language that will be used in the future (and it's useful to know)

Master Delphi - as a base

uniGui - to group all this.

UniGui is a very good choice ;)

Link to comment
Share on other sites

  • 5 months later...
On 9/17/2021 at 12:55 AM, irigsoft said:

Thank You,

In the beginning I needed help too - and I still don't know javascript, but here is a programming language that will be used in the future (and it's useful to know)

Master Delphi - as a base

uniGui - to group all this.

UniGui is a very good choice ;)


Hello irigsoft , Jrp
         How to change the title of a new browser tab when it is opened ? The title  is the same as the stored file on the server, but it is not the original file name( When uploading the file, I changed the original file name  ). I want the title to be the original filename, also when downloading and saving.

 Best Regards

Link to comment
Share on other sites

1 hour ago, bgxbd said:


Hello irigsoft , Jrp
         How to change the title of a new browser tab when it is opened ? The title  is the same as the stored file on the server, but it is not the original file name( When uploading the file, I changed the original file name  ). I want the title to be the original filename, also when downloading and saving.

 Best Regards

maybe this will help:

https://stackoverflow.com/questions/8051811/how-to-show-window-title-using-window-open

https://social.msdn.microsoft.com/Forums/en-US/b77d5197-c7cc-447d-8a04-86495e40188d/how-to-give-window-title-in-windowopen-javascript-method?forum=aspgettingstarted

Link to comment
Share on other sites

On 3/1/2022 at 3:01 PM, irigsoft said:
    var myWindow = window.open('', '', 'width=600,height=400');
     setTimeout(function(){ myWindow.document.title = 'my new title'; }, 1000);

Thanks very much.  
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...