Default window size for webhelp?

Post here questions and problems related to editing and publishing DITA content.
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Default window size for webhelp?

Post by shudson310 »

I have a requirement to force the initial window size for webhelp content to 580x700. How can I set this initial window size? I've tried setting:

Code: Select all


<script Language="JavaScript">
var width=580;
var height=700;
self.moveTo((screen.availwidth-width)/2,(screen.availheight-height)/2);
self.resizeTo(width,height);
</script>
in wt_index.html, wt_search.html, wt_terms.html and wt_topic.html, but it does not appear to change the default window size.
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
bogdan_cercelaru
Posts: 222
Joined: Tue Jul 01, 2014 11:48 am

Re: Default window size for webhelp?

Post by bogdan_cercelaru »

Hello,

You cannot resize or set the position of a browser window on the page load.
You can change only the properties of a new window opened by your script. This means that you should open a new window and set the properties you want: width, height, offset top and offset left.
Here is the script that will do this:

Code: Select all


<script>
var myWindow;

var width=580;
var height=700;
var availHeight = screen.availHeight;
var availWidth = screen.availWidth;
var positionX = (availWidth-width)/2;
var positionY = (availHeight-height)/2;
var requestedURL = window.location;

if (window.name!=="myWindow") {
window.document.write("<p>This page open a new WebHelp window!</p>");
myWindow = window.open(requestedURL, "myWindow", "width=" + width + ", height=" + height + ", left=" + positionX + ", top=" + positionY);
myWindow.focus();
window.stop();
}
</script>
You have to include it in the wt_index.html, wt_search.html, wt_terms.html and wt_topic.html files.


Regards,
Bogdan
Bogdan Cercelaru
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply