Default window size for webhelp?

shudson310
Posts: 125
Location: USA

Default window size for webhelp?

Tue Jan 03, 2017 7:52 pm

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
Content Strategist
Jeppesen
Site: jeppesen.com
bogdan_cercelaru
Posts: 203

Re: Default window size for webhelp?

Wed Jan 04, 2017 5:32 pm

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

Return to “DITA (Editing and Publishing DITA Content)”

Who is online

Users browsing this forum: No registered users and 0 guests