⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 displaycontent.js

📁 一个真正的CMS系统,可以完全实现建站自动化,用.NET开发.
💻 JS
字号:
/*
 * This function parses &-separated name=value 
 * argument pairs from the query string of the URL. 
 * It stores the name=value pairs in 
 * properties of an object and then returns that object
 */

function getArgs(fullQuery) {
    var args = new Object();

    // Get Query String (go past ? in first char)
    var query = fullQuery.substring(1); 

    // Split query at the &
    var pairs = query.split("&"); 
    
    // Begin loop through the querystring
    for(var i = 0; i < pairs.length; i++)
    {

        // Look for "name=value"
        var pos = pairs[i].indexOf('='); 
        // if not found, skip to next
        if (pos == -1) continue; 
        // Extract the name
        var argname = pairs[i].substring(0,pos); 
        
        // Extract the value
        var value = pairs[i].substring(pos+1); 
        // Store as a property
        args[argname] = unescape(value); 
    }
    return args; // Return the Object
}

function cookiesAccepted()
{
    var retval = false;

    var testCookieSet = new Cookie(document, "test", 0.01, "/");
    testCookieSet.testStr = "cookie test";
    testCookieSet.store();

    var testCookieGet = new Cookie(document, "test");
    if (testCookieGet.load())
    {
        if (testCookieGet.testStr.indexOf("cookie test") != -1)
        {
            retval = true;
            testCookieGet.remove();
        }
    }

    return retval;
}

function displayContent()
{
    var queryString = document.location.search;
    var args = getArgs(queryString);
    var url;
    var newURL;

    // if there is a 'skipReload' parameter in the query string, let the
    // topic display.  Otherwise, read the destContent cookie to see
    // what topic should be displayed and set skipReload when issuing
    // the URL of the desired topic.
    if (!args['skipReload'])
    {
        // First, try to read data stored in the cookie. If the cookie is not
        // defined do nothing and let the page display.
        //
        // Remove the cookie after using it because displayContent is going
        // to be called again when we load the actual topic.  The second
        var destContent = new Cookie(document, "destContent");
        if (destContent.load())
        {
            url = unescape(destContent.url);
            if ((url != null) && (url.length > 0))
            {
                newURL = appendQuery(url, '?skipReload=true');
                debug("displayContent: skipReload, newURL(" + newURL.length + ")=" + newURL);
                document.location.replace(newURL);
            }

            destContent.remove();
        }
    }
}

//
// called via onLoad from all topic pages
//
function displayInFrames()
{
// debugger;
    var queryString = document.location.search;
    var args = getArgs(queryString);

    // if there is a 'skipReload' parameter in the query string, 
    // just let the topic be displayed.
    // Otherwise, the browser has been sent directly to
    // a topic and we want to display the topic in the frameset
    // with the TOC properly expended.  Set cookies and display
    // index.html to make that happen.
    if (!args['skipReload'])
    {

        if (!cookiesAccepted())
        {
            var alertStr = "SiteServer CMS Help uses cookies to enable coordination\n" +
                           " of displayed topics with the Table of Contents.\n\n" +
                           "Your browser is currently not accepting cookies. Please enable\n" +
                           "cookies to access SiteServer CMS Help.";
            alert(alertStr);
            return;
        }

        // Create the cookie we'll use to communicate the URL of this topic
        // to content.html.
        // Since we're using the '/' path, this cookie will be accessible
        // to all web pages on the same "server" as this file.
        //
        // set two cookies, one for the content pane and one for the
        // TOC pane.  That way each pane can clear its cookie after it
        // reads it and order doesn't matter.
        var destContent = new Cookie(document, "destContent", 1, "/");
        destContent.remove();
        destContent.url = escape(window.location.href);
        
        var destTOC = new Cookie(document, "destTOC", 1, "/");
        destTOC.url = escape(window.location.href);

        // Store the cookie values, even if they were already stored, so that the 
        // expiration date will be reset from this most recent visit.
        destContent.store();
        destTOC.store();
        
        // load the index.html page, which will look up the cookie and do the
        // right thing in the TOC and content panes.
        indexLocation = document.links[0].href;

        setCookie('bannerMode', 'toc');
        top.document.location = indexLocation;
    }    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -