Remove Save Dialog Popup If PDF Is Modified in JPDFNotes


Once a PDF file is loaded in your JPDFNotesBean component, anything you do to the any of the pages will activate the save dialog window in case your code will close the PDF file. Say you want to save the modified actions of the PDF file in the database and you want the PDF pages’ display to stay as is and the display changes will take effect through calling your code, you can nullify the save dialog popup from appearing by calling the setModified() method before loading the file.

That way, if an existing file is currently loaded, the setModified() method will treat the currently existing file as having never been modified which can then load the next PDF file without ever prompting the save dialog popup to appear.

1
2
MyJPDFNotesBean.setModified(false);
MyJPDFNotesBean.loadPDF(my_byte_array);

Found this post useful? Buy me a cup of coffee or help support the sponsors on the right.

Javascript: Check If Popup Window Exists Using Its Window Name


When you create a popup window in Javascript, you use the function window.open(). The second parameter, refers to the window name which, usually is useful to avoid duplicates if you have a purpose of not having duplicates. Because of this property, the window name can be used to check if a popup window of that name exists or not.

Although there is no direct way to detect if a popup window with that name exists or not, what you can do is place the window name in an array object then browse the array’s contents to see if the window name exists or not.

?View Code JAVASCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
var winnames = new Array();
var ctr = 0;
 
function doesPopupExist(window_name) {
  var exist = false;
  for (i=0; i<winnames.length; i++) {
    if (winnames[i] == window_name) {
      exist = true;
      break;
    }
  }
 
  return exist;
}

Adding the window name to the array object, you can do this.

?View Code JAVASCRIPT
1
winnamess[ctr] = window_name;

Then you can use the doesPopupExist() function to see whether the popup window with that name exists or not.

Found this post useful? Buy me a cup of coffee or help support the sponsors on the right.

Javascript: Center Popup Window Based On Browser Position


Here is a short code to center your popup window based on the browser’s position using Javascript. The variable popW and popH hold constant width and height values of the popup window wheres the variables w and h hold the browser’s location on the screen.

?View Code JAVASCRIPT
1
2
3
4
var w = document.body.clientWidth, h = document.body.clientHeight;
var popW = 350, popH = 200;
var leftPos = (w - popW) / 2, topPos = (h - popH) / 2;
window.open('', 'list','width=' + popW + ',height=' + popH + ',top=' + topPos + ', left=' + leftPos);

Found this post useful? Buy me a cup of coffee or help support the sponsors on the right.

Related Posts with Thumbnails