📄 page.js
字号:
//> @classMethod Page.scrollTo()// Scroll the window to a specified top and left coordinate.//// @param left (number) new left coordinate for window// @param top (number) new top coordinate for window// @visibility external//<scrollTo : function (top, left) { window.scroll(top, left);},//> @classMethod Page.getWidth()// Get the width of the visible portion of the window, not including browser chrome or the// scrollbar area.// @group sizing//// @param [wd] (object) the window object//// @return (number) width of the page// @visibility external//<leaveScrollbarGap : isc.Browser.isMoz && isc.Browser.geckoVersion < 20051107,getWidth : (isc.Browser.isNS ? // isNS: Netscape browsers (inc.Moz, Firefox) and also Safari function (wd, recalculate) { if (!wd) wd = window; if (isc.Browser.isMoz && wd == window && !recalculate) { // see comments at the end of Canvas.js about avoiding touching window.innerWidth. if (this.width != null) { return this.width - (this.leaveScrollbarGap ? (isc.Element ? isc.Element.getNativeScrollbarSize() : 16) : 0 ); } // If we were unable to get the page width, return an arbitrary value (500) // this is probably due to the page not being fully loaded. // This method is commonly called in order to size percentage-sized widgets // correctly - therefore fire a page-resized event on load in this case // to fix any incorrectly sized percentage width widgets. //>DEBUG // Warn this at the 'info' level - Not much a developer can do about this, but it // can be valuable for us to see the issue. this.logInfo("NOTE: isc.Page.getWidth() unable to determine page width. Returning 500", "sizing"); //<DEBUG return 500; } else { // If the body has been written out, use body.clientWidth to ensure we get the // size inside any scrollbars var useClientWidth = !isc.Browser.isStrict && !this.leaveScrollbarGap && isc.Browser.geckoVersion >= 20051111 && wd.document.body != null, width; if (useClientWidth) { width = wd.document.body.clientWidth; } // Catch the case where we didn't pick up a width from the body if (width == null || width == 0) { width = wd.innerWidth; } if (wd == window) this.width = width; return width; } }:// isc.Browser.isIE || isc.Browser.isOpera function (wd) { if (!wd) wd = window; var documentBody = wd.document.body; if (isc.Browser.isStrict && !isc.Browser.isOpera) documentBody = wd.document.documentElement; if (documentBody) { // NOTE: MacIE will show scrollbars if you draw within a (native) scrollbar width of // the edge of the page, so the available space is less than clientWidth. return documentBody.clientWidth } else { // As in the Moz case, if we were unable to determine the page width, fire a // page-resized event on load to fix any incorrectly sized percentage width // widgets. if (!isc.Page.isLoaded()) { isc.Page.setEvent("load", "isc.EH._pageResize()", isc.Page.FIRE_ONCE); } //>DEBUG this.logWarn("NOTE: isc.Page.getWidth() called before <BODY> tag was written out -- " + "value cannot be determined. Returning 500"); //<DEBUG return 500; } } ),//> @classMethod Page.getHeight()// Get the height of the visible portion of the window, not including browser chrome or the// scrollbar area.// @group sizing//// @param [wd] (object) the window object//// @return (number) height of the page// @visibility external//<getHeight : (isc.Browser.isNS ? function (wd, recalculate) { if (!wd) wd = window; if (isc.Browser.isMoz && wd == window && !recalculate) { // see comments at the end of Canvas.js if (this.height != null) return this.height; return 500; } else { // If the body has been written out, use body.clientWidth to ensure we get the // size inside any scrollbars var useClientHeight = !isc.Browser.isStrict && isc.Browser.geckoVersion >= 20051111 && wd.document.body != null, height; if (useClientHeight) { height = wd.document.body.clientHeight; } if (height == null || height == 0) { height = wd.innerHeight; } if (wd == window) this.height = height; return height; } }: // isc.Browser.isIE || isc.Browser.isOpera function (wd) { if (!wd) wd = window; var documentBody = wd.document.body; // In Opera it appears that document.body.clientWidth / height returns the size // (inside scrollbars) even in strict mode if (isc.Browser.isStrict && !isc.Browser.isOpera) documentBody = wd.document.documentElement; if (documentBody) { return documentBody.clientHeight; } else { //>DEBUG this.logWarn("NOTE: isc.Page.getHeight() called before <BODY> tag was written out -- value cannot be determined. Returning 500"); //<DEBUG return 500; } }),//> @classMethod Page.getScrollWidth()// Get the width of the window contents as they have been drawn.// If the page scrolls, this may be larger than the page.getWidth().// @group sizing//// @return (number) width of the page as drawn// @visibility external//<getScrollWidth : (isc.Browser.isNS ? function (theDoc) { var theDoc = theDoc || document; return theDoc.width }:// isc.Browser.isIE function (theDoc) { var theDoc = theDoc || document; if (theDoc == null || theDoc.body == null) return 500; if (isc.Browser.version >= 6) { // in IE6 in standards compliant mode (DOCTYPE HTML 4 Transitional/Strict), IE hides the // window viewport size in window.document.documentElement, and document.body only // reports the size of the drawn content. return Math.max(theDoc.body.scrollWidth, theDoc.documentElement.clientWidth); } return theDoc.body.scrollWidth; }),//> @classMethod Page.getScrollHeight()// Get the height of the window contents as they have been drawn.// If the page scrolls, this may be larger than the page.getHeight().// @group sizing//// @return (number) height of the page as drawn// @visibility external//<getScrollHeight : (isc.Browser.isNS ? function (theDoc) { var theDoc = theDoc || document; // In Moz 1.0 and later we can get the proper value via document.body.scrollheight var scrollHeight = theDoc.body.scrollHeight; if (isc.isA.Number(scrollHeight)) return scrollHeight; } :// isc.Browser.isIE function (theDoc) { var theDoc = theDoc || document; if (theDoc == null || theDoc.body == null) return 800; if (isc.Browser.version >= 6) { // in IE6 in standards compliant mode (DOCTYPE HTML 4 Transitional/Strict), IE // hides the window viewport size in window.document.documentElement, and // document.body only reports the size of the drawn content. return Math.max(theDoc.body.scrollHeight, theDoc.documentElement.clientHeight); } return theDoc.body.scrollHeight; }),//> @classMethod Page.getScrollLeft()// Get the amount that the browser window has been scrolled horizontally.// @group sizing//// @return (number) horizontal scroll amount// @visibility external//<getScrollLeft : (isc.Browser.isNS ? function () { return window.pageXOffset; }: // isc.Browser.isIE function () { if (document == null || document.body == null) return 0; // in IE6 in standards compliant mode (DOCTYPE HTML 4 Transitional/Strict) // document.body.scrollLeft and document.body.scrollTop are always zero while // document.documentElement.scrollLeft and scrollTop reflect the actual browser scrollDeltas return (isc.Browser.isStrict ? document.documentElement.scrollLeft : document.body.scrollLeft); }),//> @classMethod Page.getScrollTop()// Get the amount that the browser window has been scrolled vertically.// @group sizing//// @return (number) vertical scroll amount// @visibility external//<getScrollTop : (isc.Browser.isNS ? function () { return window.pageYOffset; }:// isc.Browser.isIE function () { if (document == null || document.body == null) return 0; // in IE6 in standards compliant mode (DOCTYPE HTML 4 Transitional/Strict) // document.body.scrollLeft and document.body.scrollTop are always zero while // document.documentElement.scrollLeft and scrollTop reflect the actual browser scrollDeltas return (isc.Browser.isStrict ? document.documentElement.scrollTop : document.body.scrollTop); }),//> @classMethod Page.getScreenWidth()// Get the width of the user's screen, in pixels.// @visibility external//<getScreenWidth : function () { return screen.width },//> @classMethod Page.getScreenHeight()// Get the height of the user's screen, in pixels.// @visibility external//<getScreenHeight : function () { return screen.height },//> @classMethod Page.getWindowRect()// return the coordinates of the window wd, or current window if wd isn't specified// in IE this doesn't include scrollbar size (if any)// @group positioning, sizing// // @param [wd] (object) the window object//// @return (object) {left:x, top:y, width:w, height:h}//<getWindowRect : function (wd) { if (!wd) wd = window; return { left: (isc.Browser.isIE || isc.Browser.isOpera ? wd.screenLeft : wd.screenX), top: (isc.Browser.isIE || isc.Browser.isOpera ? wd.screenTop : wd.screenY), width: isc.Page.getWidth(wd), height: isc.Page.getHeight(wd) };}, setUnloadMessage : function (message) { if (message == null) window.onbeforeunload = null; else window.onbeforeunload = function () { return message; };},// --------------------------------------------------------------------------------------------//> @classMethod Page.goBack()// Go back in the browser's history.<br><br>//// If the history is empty and the window.opener is set, we assume we're a child window and just// close the window.//// @visibility external//<goBack : function () { if (history.length == 0 && window.opener) { window.close(); } else { history.back(); }},//> @classMethod Page.print()// Print the window. This brings up the print dialog and the user actually// starts printing.//// Note: In IE4, you have to have already created a BODY tag in the window for this to work.//// @param wd (window) pointer to a window or frame to print// default is the current window//<print : function (wd) { // default to the current window if (!wd) wd = window; if (wd.print) { wd.print(); } else { // get a pointer to the document of the window var doc = wd.document; // if not found, bail if (!doc || !doc.body) { //>DEBUG this.logError("isc.Page.print() called on a window that doesn't have a document.body defined. Exiting."); //<DEBUG return; } // The following works in Windows IE only // insert a built-in active-x control that will do the printing for us if (isc.Browser.isWin) { doc.body.insertAdjacentHTML('beforeEnd', '<OBJECT ID="printControl" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>' ); // get a pointer to the printControl var control = doc.all.printControl; if (!control) { //>DEBUG this.logError("isc.Page.print() couldn't create or find print control. Exiting."); //<DEBUG return; } // call the print command // -- pass '2' below to skip the dialog box control.ExecWB(6, 1); // remove the control, since we don't need it anymore control.outerHTML = ""; } else { alert("Choose 'Print...' from the File menu to print this page."); } }},// --------------------------------------------------------------------------------------------// Observation from static scope; for comments, see class.observeobserve : function (object, methodName, action) { // create a dummy instance of Class so we can use it for calling "observe" statically var observer = isc.Class.create(); return observer.observe(object, methodName, action);},//> @classMethod Page.checkBrowserAndRedirect(URL)// Check that the browser is supported by the Isomorphic SmartClient system.// If not, redirect to specified URL. <br>// If no URL is passed in we will use <code>Page.defaultUnsupportedBrowserURL</code> as// a default.//// @param [URL] (string) URL of redirect page. May include Isomorphic special directories such as [SKIN].// @see Page.defaultUnsupportedBrowserURL// @visibility external//<checkBrowserAndRedirect : function (URL) { // if the browser is not supported, redirect them to the "unsupported_browser.html" page if (URL == null) URL = isc.Page.defaultUnsupportedBrowserURL; if (!isc.Browser.isSupported) { var UNSUPPORTED_BROWSER_DETECTED = true; window.location.replace(isc.Page.getURL(URL)); }}}); // END isc.Page.addClassMethods()if (isc.Page.isXHTML()) isc.nbsp = isc.xnbsp;// set the default directories for files to what's set in the window, if anythingisc.Page.setDirectories();// in Moz get the page size right now so it's available even before the Page is done loading// without triggering the "zero width bug"if (isc.Browser.isMoz) { isc.Page.getWidth(null, true); isc.Page.getHeight(null, true);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -