0

我在 HelpNDoc 个人版http://www.helpndoc.com/的帮助下创建了一个 HTML 文档

我使用了随它提供的默认模板,该模板在几乎所有浏览器中都能很好地加载,除了 google chrome,模板不加载,因为我在 HTML 方面不是那么先进,所以我想你可以提供一些帮助。

错误:

Unsafe JavaScript attempt to access frame with URL file:///C:/Users/lenovo        
/Documents     /HelpNDoc/Output/html/testingproject.html from frame with URL   
file:///C:/Users/lenovo/Documents/HelpNDoc/Output/html/toc.html. Domains,   
protocols and ports must match.
toc.html:36

Uncaught TypeError: Cannot call method 'lastIndexOf' of undefined toc.html:36

Unsafe JavaScript attempt to access frame with URL file:///C:/Users/lenovo  
/Documents/HelpNDoc/Output/html/toc.html from frame with URL file:///C:/Users
/lenovo/Documents/HelpNDoc/Output/html/Introduction.html. Domains, protocols and 
ports must match.
Introduction.html:27

Unsafe JavaScript attempt to access frame with URL file:///C:/Users/lenovo   
/Documents/HelpNDoc/Output/html/toc.html from frame with URL file:///C:/Users   
/lenovo/Documents/HelpNDoc/Output/html/Systemrequirements.html. Domains,  
protocols    and ports must match.

Systemrequirements.html:27

Unsafe JavaScript attempt to access frame with URL file:///C:/Users/lenovo 
/Documents/HelpNDoc/Output/html/toc.html from frame with URL file:///C:/Users/lenovo
/Documents/HelpNDoc/Output/html/Gettinghelp.html. Domains, protocols and ports  
must   match.
Gettinghelp.html:27

toc.html 看起来像 - 我在第 36 行之前和之后添加内容

<script type="text/javascript" src="js/searchdata.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript" src="js/jquery.dynatree.min.js"></script>
<script type="text/javascript" src="js/hndjsse.js"></script>
<script type="text/javascript">

var bSearchDataLoaded = true;
var sHelpIdToActivate = '';

$(document).ready(function()
{
   var sAnchorName = 
   top.location.href.substring(top.location.href.lastIndexOf("#") + 1, 
   top.location.href.length);
        var nSelectedTab = 0;
        if (sAnchorName == '_index') nSelectedTab = 1
        else if (sAnchorName == '_search') nSelectedTab = 
    2;          
        $("#tabs").tabs({
            selected: nSelectedTab,
            select: function(event, ui) { HideKwPopup(); }
        });

        // Toc
        $("#tab-toc").dynatree({
            clickFolderMode: 1,
            debugLevel: 0,
            imagePath: 'css/dynatree/chm/',
            onActivate: function(node){
                if ($("#tab-keywords") && $("#tab-
keywords").dynatree && $("#tab-keywords").dynatree("getTree") && $("#tab-
keywords").dynatree("getTree").activateKey)
                    $("#tab-
keywords").dynatree("getTree").activateKey(null);
                if(node.data.href && node.data.href != '#'){
                    window.open(node.data.href, 
node.data.target);
                }
            }
        });

Introduction.html 看起来像 - 我在第 27 行之前和之后添加了行

</style>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/hnd.js"></script>
<script type="text/javascript"><!--
if (top.frames.length == 0)
{
            var sTopicUrl = 
          top.location.href.substring(top.location.href.lastIndexOf("/") + 1, 
          top.location.href.length);
            top.location.href = "testingproject.html?" + sTopicUrl;
        }
        else if (top && top.FrameTOC && top.FrameTOC.SelectTocItem)
        {
            top.FrameTOC.SelectTocItem("Introduction");
        }
</script>

</head>

system requirements.html 看起来像

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/hnd.js"></script>
<script type="text/javascript"><!--
if (top.frames.length == 0)
        {
            var sTopicUrl = 
top.location.href.substring(top.location.href.lastIndexOf("/") + 1, 
top.location.href.length);
            top.location.href = "testingproject.html?" + sTopicUrl;
        }
        else if (top && top.FrameTOC && top.FrameTOC.SelectTocItem)
        {
            top.FrameTOC.SelectTocItem("Systemrequirements");
        }
    </script>

 </head>

gettinghelp.html 看起来像 -

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/hnd.js"></script>
<script type="text/javascript"><!--
    if (top.frames.length == 0)
    {
        var sTopicUrl = 
 top.location.href.substring(top.location.href.lastIndexOf("/") + 1, 
 top.location.href.length);
        top.location.href = "testingproject.html?" + sTopicUrl;
    }
    else if (top && top.FrameTOC && top.FrameTOC.SelectTocItem)
    {
        top.FrameTOC.SelectTocItem("Gettinghelp");
    }
</script>
</head>

非常感谢任何帮助。谢谢埃迪

4

2 回答 2

0

此问题是由于本地启动某些 JavaScript 时 Google Chrome 的安全限制所致。当文档上传到网络服务器时,这不会发生。这在这里解释:http ://www.helpndoc.com/sites/default/files/documentation/html/index.html?GoogleChromeshowsanerrorwhensear.html

@powtac 也是正确的,这是重复的:不安全的 JavaScript 尝试使用 URL 访问框架

于 2012-06-10T13:57:26.947 回答
0

这只是 toc.html,但如果这能解决该文件的问题,我会很高兴:

<script type="text/javascript" src="js/searchdata.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript" src="js/jquery.dynatree.min.js"></script>
<script type="text/javascript" src="js/hndjsse.js"></script>
<script type="text/javascript">

var bSearchDataLoaded = true;
var sHelpIdToActivate = '';

$(document).ready(function()
{
var sAnchorName = 
top.location.href.substring(top.location.href.lastIndexOf("#") + 1, 
top.location.href.length);
var nSelectedTab = 0;
if (sAnchorName == '_index'){ 
    nSelectedTab = 1
}
else if (sAnchorName == '_search'){
    nSelectedTab = 2;          
    $("#tabs").tabs({
        selected: nSelectedTab,
        select: function(event, ui) { HideKwPopup(); }
    });
}

// Toc
$("#tab-toc").dynatree({
    clickFolderMode: 1,
    debugLevel: 0,
    imagePath: 'css/dynatree/chm/',
    onActivate: function(node){
        if ($("#tab-keywords") && $("#tab-keywords").dynatree && $("#tab-keywords").dynatree("getTree") && $("#tab-keywords").dynatree("getTree").activateKey){
            $("#tab-keywords").dynatree("getTree").activateKey(null);
            if(node.data.href && node.data.href != '#'){
                window.open(node.data.href, node.data.target);
            }
        }
    }
});
});

如果这行得通,那只是在某处遗漏了一个括号……如果不是,那可能是一个更深层次的问题,我无能为力:)

希望这可以帮助

于 2012-05-31T09:43:23.993 回答