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
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
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
Related
Here is the HTML head:
<head>
<link type='text/css' rel='stylesheet' href='style.css'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript" href='script.js'></script>
</head>
Here are the contents of the jQuery file:
$(document).ready(function() {
var $block_number = prompt('How many blocks?');
function writeBoard() {
while ($.isNumeric($block_number) === false && $block_number < 150) {
$block_number = prompt('How many blocks?');
}
for (var i = 0; i < $block_number; i++) {
$('#board').prepend("<div class='block'></div>");
}
};
writeBoard();
$(".block").on("mouseover", function () {
$(this).css("background-color", "black");
});
$('#redo').on('click', function () {
$('.block').css('background-color', 'white');
$block_number = prompt('How many blocks?');
writeBoard();
});
});
It doesn't seem to be working when the page is loaded locally as it was on jsfiddle for some reason. Any thoughts?
Fiddle: http://jsfiddle.net/zfiscr/9dutj67b/
Your script tag should be as follows :
<script type="text/javascript" src="script.js"></script>
instead of
<script type="text/javascript" href="script.js"></script>
Hope that helps!!!
Script has src , CSS has href :)
<script type="text/javascript" src='script.js'></script>
is correct.
Why ? Please check Here
My website works fine and all javascript files also work in my computer, but after publishing to the server all files work except super.js file. Links in menu supposed to work but it shows just "#".
<script type="text/javascript" src="/App_Themes/standart2/js/jquery.min.js"></script>
<script type="text/javascript" src="/App_Themes/standart2/js/bootstrap.min.js"></script>
**<script type="text/javascript" src="/App_Themes/standart2/js/super.js"></script>**
<script type="text/javascript" src="/newfiles/calendar/js/jquery-ui.js"></script>
<script type="text/javascript" src="/newfiles/slider/script/jquery.easing-1.3.js"></script>
<script type="text/javascript" src="/newfiles/slider/script/jquery.easing.compatibility.js"></script>
<script type="text/javascript" src="/newfiles/slider/script/jquery.jcarousellite.js"></script>
<script type="text/javascript" src="/newfiles/slider/script/jquery.jcarousellite.min.js"></script>
<script type="text/javascript" src="/newfiles/slider/script/jquery.mousewheel-3.1.12.js"></script>
Here is a snippet code to my file [a link] (http://jsfiddle.net/programmer777/oxj69tum/embedded/result/)! i don't understand a problem, looked everywhere, but couldn't find a solution.
$(document).ready(function () {
var menuLinksNew = $(".menuH>li>a");
var pathname = $(location).attr('pathname');
if (pathname.substring(1, 3) == "eng") {
$(menuLinksNew[0]).attr("href", "/about");
$(menuLinksNew[0]).text("About");
}
else if (pathname.substring(1, 3) == "fr") {
$(menuLinksNew[0]).attr("href", "/about");
$(menuLinksNew[0]).text('About');
}
var submenuNew1 = $(".menuH ul a");
if (pathname.substring(1, 3) == "eng") {
$(submenuNew1[0]).attr("href", "/eng/about/info");
$(submenuNew1[0]).children("h5").text("blah");
$(submenuNew1[1]).attr("href", "/eng/about/info/1");
$(submenuNew1[1]).children("h5").text("blah");
$(submenuNew1[2]).attr("href", "/eng/about/info");
$(submenuNew1[2]).children("small").text('blah');
$(submenuNew1[3]).attr("href", "/eng/about/info");
$(submenuNew1[3]).children("small").text('blah');
}
else if (pathname.substring(1, 3) == "fr") {
$(submenuNew1[0]).attr("href", "/fr/about/info");
$(submenuNew1[0]).children("h5").text("blah");
$(submenuNew1[1]).attr("href", "/fr/about/info/1");
$(submenuNew1[1]).children("h5").text("blah");
$(submenuNew1[2]).attr("href", "/fr/about/info");
$(submenuNew1[2]).children("small").text('blah');
$(submenuNew1[3]).attr("href", "/fr/about/info");
$(submenuNew1[3]).children("small").text('blah');
});
if (pathname.substring(1, 3) == "eng") {
$(submenuNew1[0]).attr("href", "/eng/about/info");
$(submenuNew1[0]).children("h5").text("blah");
$(submenuNew1[1]).attr("href", "/eng/about/info/1");
$(submenuNew1[1]).children("h5").text("blah");
$(submenuNew1[2]).attr("href", "/eng/about/info");
$(submenuNew1[2]).children("small").text('blah');
$(submenuNew1[3]).attr("href", "/eng/about/info");
$(submenuNew1[3]).children("small").text('blah');
**}**
else if (pathname.substring(1, 3) == "fr") {
The brace after before else if is missing.
when i try to use javascript to start the unity webplayer inside a xhtml-file the webpage cant detect the webplayer and asks me to download it.
Same source(generated by unity itself) with .html works fine
why? :O
<script type='text/javascript' src='https://ssl-webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/jquery.min.js'></script>
<script type="text/javascript">
<!--
var unityObjectUrl = "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js";
if (document.location.protocol == 'https:')
unityObjectUrl = unityObjectUrl.replace("http://", "https://ssl-");
document.write('<script type="text\/javascript" src="' + unityObjectUrl + '"><\/script>');
-->
</script>
<script type="text/javascript">
<!--
var config = {
width: 512,
height: 260,
params: { enableDebugging:"0" }
};
var u = new UnityObject2(config);
jQuery(function() {
var $missingScreen = jQuery("#unityPlayer").find(".missing");
var $brokenScreen = jQuery("#unityPlayer").find(".broken");
$missingScreen.hide();
$brokenScreen.hide();
u.observeProgress(function (progress) {
switch(progress.pluginStatus) {
case "broken":
$brokenScreen.find("a").click(function (e) {
e.stopPropagation();
e.preventDefault();
u.installPlugin();
return false;
});
$brokenScreen.show();
break;
case "missing":
$missingScreen.find("a").click(function (e) {
e.stopPropagation();
e.preventDefault();
u.installPlugin();
return false;
});
$missingScreen.show();
break;
case "installed":
$missingScreen.remove();
break;
case "first":
break;
}
});
u.initPlugin(jQuery("#unityPlayer")[0], "BulletImages.unity3d");
});
-->
</script>
<div id="unityPlayer">
<div class="missing">
<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
</a>
</div>
</div>
JavaScript isn't allowed to use document.write() on XHTML pages.
Note the offending snippet:
<script type="text/javascript">
<!--
var unityObjectUrl = "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js";
if (document.location.protocol == 'https:')
unityObjectUrl = unityObjectUrl.replace("http://", "https://ssl-");
document.write('<script type="text\/javascript" src="' + unityObjectUrl + '"><\/script>');
-->
</script>
You may notice the script in question is performing a very simple operation. If you know your deployment, you can strip it and include the result plainly:
If deploying to HTTP website:
<script type="text/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js"></script>
If deploying to HTTPS website:
<script type="text/javascript" src="https://ssl-webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js"></script>
If you're not sure, an ideal fix would be to edit the page's DOM, but a quick and dirty workaround is to edit a node's innerHTML directly.
My html page has the following 2 scripts:
1.
<script language="javascript" type="text/javascript">
document.write("<iframe id=\"frame\" src=\"http://mywebsite.com/" + "\"scrolling=\"yes\" width=\"850\" height=\"575\" frameborder=0></iframe>");
</script>
2.
<script type="text/javascript">
var myframe = document.getElementById("frame");
if (myframe) {
var myframe_window = document.getElementById('frame').contentWindow;
if (myframe_window) {
myframe_window.confirm = window.confirm;
}
}
</script>
I'm trying to override a methiod in iFrame, but cannot get its id.
What am I doing wrong?
I have some script tag like this:
<script src="cordova-2.5.0.js"></script>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery.mobile-1.1.1.min.js"></script>
<script src="js/jquery.xdomainajax.js"></script>
<script src="js/xml2json.js"></script>
<script src="js/ZipPlugin.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/jquery.ui.touch-punch.min.js"></script>
<script src="js/prefixfree.min.js"></script>
This is my app i wrote using phonegap for android but i want to use code in web. And i dont use all for web page.
Have any way to do it like using if else like this in html:
if(anything) {
<script src="cordova-2.5.0.js"></script>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery.mobile-1.1.1.min.js"></script>
<script src="js/jquery.xdomainajax.js"></script>
<script src="js/xml2json.js"></script>
<script src="js/prefixfree.min.js"></script>
} else {
<script src="js/ZipPlugin.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/jquery.ui.touch-punch.min.js"></script>
}
I am a dumper, please help me.
Thanks for reading!!!
Edit:
if i want to change my script tag:
<script src="js/prefixfree.min.js"></script>
Become like this:
<script src="http://smartphone.thnt.vn/VietGames/GhepTranhTu/Web/js/prefixfree.min.js"></script>
Have anyway to make a variable like:
var key ="http://smartphone.thnt.vn/VietGames/GhepTranhTu/Web/"
And then use in tag like this:
<script src = "key + 'js/prefixfree.min.js'"></script>
How about this,
function registerScript(scriptPath) {
var scriptTag = document.createElement('script');
scriptTag.type = 'text/javascript';
scriptTag.async = true;
scriptTag.src = scriptPath;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(scriptTag, s);
}
if (anything) {
registerScript("cordova-2.5.0.js");
}
For the first part. you can do this:
if (anything) {
$('head').append('<script src="cordova-2.5.0.js"></script>')
.append('<script src="js/jquery-1.7.2.min.js"></script>')
.append('<script src="js/jquery.mobile-1.1.1.min.js"></script>')
.append('<script src="js/jquery.xdomainajax.js"></script>')
.append('<script src="js/xml2json.js"></script>')
.append('<script src="js/prefixfree.min.js"></script>')
} else {
$('head').append('<script src="js/ZipPlugin.js"></script>')
.append('<script src="js/jquery-ui.min.js"></script>')
.append('<script src="js/jquery.ui.touch-punch.min.js"></script>')
}
To change the script tag, do this:
var key ="http://smartphone.thnt.vn/VietGames/GhepTranhTu/Web/"
$('script[src="js/prefixfree.min.js"]').attr('src', key + 'js/prefixfree.min.js');
Using jquery template :
DEMO : http://jsfiddle.net/abdennour/R36Qc/3/
Your template :
<script id="myscripts" type="text/x-jquery-tmpl">
<script src="${myurl}" type="text/javascript">
{{html "</sc"+"ript>"}}
</script>
Your javascript code :
$('#myscripts').tmpl(myarray).prependTo('head')
The branching (if) is done on array of String (src of js) :
var myarray=[]
if (anything) {
myarray=[{myurl:"cordova-2.5.0.js"},
{myurl:"js/jquery-1.7.2.min.js"},
{myurl:"js/jquery.mobile-1.1.1.min.js"},
{myurl:"js/jquery.xdomainajax.js"},
{myurl:"js/xml2json.js"},
{myurl:"js/prefixfree.min.js"},
{myurl:"js/jquery.mobile-1.1.1.min.js"}
]
} else {
myarray=[{myurl:"js/ZipPlugin.js"},
{myurl:"js/jquery-ui.min.js"},
{myurl:"js/jquery.ui.touch-punch.min.js"} ]
}
See : https://stackoverflow.com/a/5462679/747579
To check result , open browser inspector :
You could make a script to create all the scripts node like:
<script>
var head= document.getElementsByTagName('head')[0];
var key = '';
if(anything) key = 'http://smartphone.thnt.vn/VietGames/GhepTranhTu/Web/';
var scripts = new Array()
scripts[0] = 'js/prefixfree.min.js';
scripts[1] = 'js/foo.js';
for(var s in scripts) {
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= key + s;
head.appendChild(script);
}
</script>
You could use pure javascript like that:
<script>
var key ="http://smartphone.thnt.vn/VietGames/GhepTranhTu/Web/",
file=document.createElement('script');
file.type = "text/javascript";
file.src = key + 'js/prefixfree.min.js';
document.getElementsByTagName("head")[0].appendChild(file);
</script>
<script>
if(foo) {
document.write('<script src="a.js"><\/script>');
} else {
document.write('<script src="b.js"><\/script>');
}
</script>
In this case document.write is a valid option. The script tags are blocking anyway.
You can include script files dynamically using JavaScript. See an example here:
Load jQuery with Javascript and use jQuery