This topic is locked

Custom Button To Launch Print View in new window

7/25/2019 6:52:47 AM
PHPRunner General questions
L
lcslouis author

I have created a Button on the View Page with the following Client Before Code

var url = new URL(location.href);

location.href="Entry_print.php?selection[]="+url.searchParams.get("editid1");


What do I need to add to it to make it open a new window in the browser?

Admin 7/25/2019

You have two options here

  1. Use Javascript's window.open function

    https://developer.mozilla.org/en-US/docs/Web/API/Window/open
  2. Or use PHPRunner's displayPopup function:

    https://xlinesoft.com/phprunner/docs/how_to_display_any_page_in_boo.htm

L
lcslouis author 7/29/2019



You have two options here

  1. Use Javascript's window.open function

    https://developer.mozilla.org/en-US/docs/Web/API/Window/open
  2. Or use PHPRunner's displayPopup function:

    https://xlinesoft.com/phprunner/docs/how_to_display_any_page_in_boo.htm



Hello,
I am using the Client Before on my button which is on a view page.



location.href="Entry_print.php?selection[]="+url.searchParams.get("editid1");

window.popup = Runner.displayPopup({
url: new URL(location.href),

width: 700,

height: 700,

header: 'Print'

});


All it does is the address bar changes to this "http://localhost:8086/Entry_view.php?editid1=1#"; but nothing else happens no popup shows.

Admin 7/29/2019

location.href is a special thing in Javascript - if you assign a value to this variable it will redirect you immediately. You should not be using it in your code if you need to open a window in popup.

L
lcslouis author 7/29/2019



location.href is a special thing in Javascript - if you assign a value to this variable it will redirect you immediately. You should not be using it in your code if you need to open a window in popup.


Ok I Just changed the code to this and still same result as previous post.

window.popup = Runner.displayPopup({
url: "Entry_print.php?selection[]="+url.searchParams.get("editid1"),

width: 700,

height: 700,

header: 'Print'

});
Admin 7/29/2019

You are referring to url variable that is not defined anywhere.
You cannot just hack your way to correct code. Start with something simple i.e. with a hardcoded URL. Once you got it working you can extend this functionality. Do not try too many things at once.

L
lcslouis author 7/30/2019



You are referring to url variable that is not defined anywhere.
You cannot just hack your way to correct code. Start with something simple i.e. with a hardcoded URL. Once you got it working you can extend this functionality. Do not try too many things at once.


ok I just hard coded google.com and i am getting the same response.

I have inspected the code in the browser

so looks like its not even generating proper code for the button event.



<a type="button" title="" class="btn btn-default

" id="New_Button" href="#" typeid="ib">

Print Confirmation </a>


In my Designer view my button item id is Print_button. but in the browser it is appearing as New_button. i would say this looks like a bug.

Admin 8/3/2019

I'm afraid you doing something wrong. Maybe delete your button and start from scratch. Do not try too many things, make sure you make the most basic code works first.