Javascript does not work fine in google chrome

2.7k views Asked by At

I created an HTML documentation with the help of HelpNDoc personal edition http://www.helpndoc.com/

I have used a default template provided with it the template loads well in almost all the browsers except for the google chrome , the template does not load , since i am not so advanced in HTML i thought you could give some help.

Errors:

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 looks like-i am adding contents before line 36 and after it

<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 looks like-i have added lines before and after line 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 looks like

<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 looks like -

<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>

Any help is highly appreciated. Thanks Eddie

2

There are 2 answers

0
Lennart On

This is just toc.html, but I'm intressted if this solves the problem for that file:

<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);
            }
        }
    }
});
});

If this works, it was just a case of missing out a bracket somewhere ... If not it is probably a deeper problem which I can't help with :)

Hope this helps

0
jonjbar On

This problem is due to security restrictions of Google Chrome when some JavaScript is launched locally. This won't happen when the documentation is uploaded on a web-server. This is explained here: http://www.helpndoc.com/sites/default/files/documentation/html/index.html?GoogleChromeshowsanerrorwhensear.html

Also @powtac is right, this is a duplicate for: Unsafe JavaScript attempt to access frame with URL