You can try opening the window with top and left parameters as shown below
<!DOCTYPE html>
<html>
<body>
<p>Click the button to open a new window with some specifications.</p>
<button onclick="myPopup('https://www.w3schools.com', 'web', 1100, 500);">Open Qries.com</button>
<script>
function myPopup(myURL, title, myWidth, myHeight) {
var left = (screen.width - myWidth)/2;
var top = (screen.height - myHeight)/4;
var myWindow = window.open(myURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + myWidth + ', height=' + myHeight + ', top=' + top + ', left=' + left);
}
</script>
</body>
</html>
You can also check it here and geeks
Updating function openLinkinNewWindowForms() to open pdfs in a new windows.
Changes: New lines added and one existing line has been commented out.
Replace the entire function with the script provided here.
It has been verified with Chrome
function openLinkinNewWindowForms()
{
//alert("clicked");
//$("#onetidDoclibViewTbl0").find("a.ms-listlink.ms-draggable").each(function(){
$(".ms-listlink").each(function(){
//alert("inside function");
if($(this).attr("href"))
{
var targetValue=$(this).attr("href");
//if(targetValue.indexOf(".aspx")>0)
//{
var anchorTag = $(this)(0);
var linkUrl=anchorTag.href;
anchorTag.removeAttribute("href");
//**Begin new Lines of Code**
var width=800;
var height=600;
var left = (screen.width - width)/2;
var top = (screen.height - height)/4;
var customClick = "window.open('"+linkUrl+"','_blank','resizable=1,scrollbars=yes,height=600,width=800,modal=yes,alwaysRaised=yes" + ", top=" + top + ", left=" + left +"')";
//**End of new Lines of Code**
//**commented out this line
//var customClick = "window.open('"+linkUrl+"','_blank','resizable=1,scrollbars=yes,height=600,width=800,modal=yes,alwaysRaised=yes')";
//window.resizeTo( 1200,800 );
anchorTag.setAttribute("onclick", customClick);
anchorTag.setAttribute("style","cursor:pointer");
//}
}
});
}