Currently, I am maintaining a web application built on asp.net, vb.net, and ajax. My goal is to open a new window from another page with specific height, width, and position when it loads.
Although I am aware of the window.open method, there are certain issues that prevent me from using it. Instead of setting the size using JavaScript on the parent page, I would like to set the size of the child page within the child page itself.
Initially, I considered using the body onload function on the master page. However, I encountered difficulties executing even a simple JavaScript function with this approach. Therefore, I believe utilizing jQuery would be more suitable to achieve my goal.
If anyone could provide assistance by sharing relevant code snippets, it would be greatly appreciated.
I have attempted to implement the following JavaScript code. While it works fine in a regular HTML page, it fails to execute when used on an asp.net master page.
function SetWindow(){
var height = 400; //Set height
var width = 400; //Set width
var name = "winname" //Set window name
var top = 20; //Set distance from top
var left = 20; //Set distance from bottom
var url = window.location.href;
if(document.location.search=='') {
newwin=window.open(url, name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
}
}
<body onload="SetWindow();">
</body>
Your assistance is sincerely appreciated.