Javascript在Google Chrome中无效

时间:2012-05-31 09:35:03

标签: javascript google-chrome helpndoc

我在HelpNDoc个人版http://www.helpndoc.com/

的帮助下创建了一个HTML文档

我使用了随附的默认模板,模板在几乎所有浏览器中加载都很好,除了谷歌浏览器,模板没有加载,因为我不是那么先进的HTML,我认为你可以提供一些帮助。 / p>

错误:

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>

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

2 个答案:

答案 0 :(得分: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);
            }
        }
    }
});
});

如果这样可行,那只是在某个地方错过了一个括号的情况......如果不是这可能是一个我无法帮助的更深层次的问题:)

希望这有帮助

答案 1 :(得分:0)

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

同样@powtac是对的,这是:Unsafe JavaScript attempt to access frame with URL

的副本