首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Javascript在google chrome中不能正常工作。

Javascript在google chrome中不能正常工作。
EN

Stack Overflow用户
提问于 2012-05-31 17:35:03
回答 2查看 2.8K关注 0票数 0

我在HelpNDoc个人版http://www.helpndoc.com/的帮助下创建了一个超文本标记语言文档

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

错误:

代码语言:javascript
复制
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行之前和之后添加内容

代码语言:javascript
复制
<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行之前和之后添加了行

代码语言:javascript
复制
</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>

系统requirements.html看起来像这样

代码语言:javascript
复制
<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看起来像-

代码语言:javascript
复制
<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>

任何帮助都是非常感谢的。谢谢埃迪

EN

回答 2

Stack Overflow用户

发布于 2012-05-31 17:43:24

这只是toc.html,但我很感兴趣,如果它能解决这个文件的问题:

代码语言:javascript
复制
<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);
            }
        }
    }
});
});

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

希望这能有所帮助

票数 0
EN

Stack Overflow用户

发布于 2012-06-10 21:57:27

这个问题是由于某些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的副本

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10830997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档