In this question I asked, how I can generate shades of one color responsive to the number of div's. #DonJuwe came up with a perfectly working solution and demo: http://jsbin.com/xakifequ/1/edit
However when I'm trying to use the code from the jsfiddle or JSBin it just doesn't work.
So I downloaded the source code from JSBin, opened the .html-file and what I got was this:
Can someone please explain me, why this happens?
As per snapshot, You are using
<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>
Replace it with
<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>
You are using protocol less Urls, i.e. //code.jquery.com/jquery-1.9.1.js, When you open a your html file like file:// then jQuery is not loaded thus desired result is not achieved.
However, if you test your html file like http://localhost/yourfile.html you will get the desired result.
Note: Use // instead of http:// when you want to inherit the protocol from the page
you missed http: in the jQuery source link. if you using online resource you should follow the url's protocol. Other wise browser will search it from local. in this way you just confused your browser... So only it happens... :D
you should use...
<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>
instead of
<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>
Related
I have installed Nicedit tool to convert <textarea> into richtext box on my pages by adding the following code as per their instructions on their website:
<script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
<script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script>
However textareas got convereted (Nicedit worked fine) ONLY on my localhost Xampp, but when i uploaded the pages online, everything works fine except for the Nicedit, it doesn't work at all.
Please note that no error messages appeared, nor with textareas the issue is that textareas appear plain just like the standard, like if I didn't install the Nicedit.
Note: I have tried the following code as well since I've seen it as an example on their page, but it doesn't work also.
<script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script> <script type="text/javascript">
//<![CDATA[
bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
//]]>
</script>.
PHP version used online is 5.6, if this would be useful info.
Since I couldn't find the reason to fix the issue that I have, I've found another tool created by the same programmer of Nicedit, it's name is CKeditor.
it's really nice, however browsing the website would take you into the direction of downloading and using JS code from your site, but I have found the following way to let it work as CDN.
First in the <head></head> tags copy the following:
<script src="https://cdn.ckeditor.com/4.7.1/basic/ckeditor.js"></script>
then inside <body></body> copy this code (presuming text1 is the name arttibute for the <textarea> that you want to convert.
<script>
CKEDITOR.replace( 'text1');
</script>
Hope this would be helpful for everyone.
I am trying to implement Highcharts to display data on my web application. At the moment, I just want to see how Highchart works on my website so I have simply copied code from this fiddle and implemented it on my site. But for some reason, the chart does not display.
It may just be my inexperience (or quite frankly, my stupidity) but I don't know why the fiddle isn't loading. Have I missed anything?
Here is what I have done:
I have added the following to the head of the page:
<script src="https://code.highcharts.com"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="javascript/chart.js"></script>
chart.js is a seperate file, which consists of all the JavaScript from the fiddle.
Whenever you observe a problem, the first thing you need to check is whether there are any errors. When it comes to Javascript, you need to check the browser console. In this case, the $ in the error message is a strong hint that you forgot to include a script tag before the other script tags having its src attribute pointing to the location of jquery.
like this:
style="text/javascript"
src="http://helplogger.googlecode.com/svn/trunk/recent-posts-with-titles-only.js"
Please help me>.......
I think this is what your trying to do, the same as you appen any JS library
<script type="text/javascript" src="http://helplogger.googlecode.com/svn/trunk/recent-posts-with-titles-only.js">
You could use <script> html's tag for that.
use:
<script src="myscripts.js"></script>
whenever the script is relative to your webpage
and use:
<script src="http://www.example.com/example.js"></script>
whenever the script is external to your webpage.
This kind of things are well documented on this webpage.
i.e. :
You could see a complet definition of how <script> tag works here.
I have searched many on this forum to hide some information in view source like script include and css, I didn't find any working solution
this is what I am doing in my php script
<html>
<head><?php include('mylibrary/my_include.php');?></head>
<body>
<div></div>
</body>
</html>
in view source I am getting like this
<html>
<head>
<!-- My function -->
<script type='text/javascript' src='Library/My_fun.js'></script>
<!-- Index -->
<link type="text/css" rel="stylesheet" href="Index/Index.css" />
<link type="text/css" rel="stylesheet" href="JS/jquery-ui.css" />
</head>
<body>
<div></div>
</body>
</html>
I would like to hide js and css in view source which are in 'mylibrary/my_include.php', Is it possible to do so ? or any alternate solution displaying only following in viewsource or any other
<head><?php include('mylibrary/my_include.php');?></head>
No.
You can't give something to the browser without giving it to the user. The user controls the browser, you do not.
I would like to hide js and css in view source which are in
'mylibrary/my_include.php', Is it possible to do so ? or any alternate
solution displaying only following in viewsource or any other
No, it is impossible to render your page without these references due to the fact using these references, the web browser knows from where to download, parse and load your resources (css, js).
But:
You can obscure/compress/minify your JS & CSS files in such a way that it would be very hard for the users to identify it correctly.
UPDATE:
Per the OP request, here is how to compress resource files:
http://refresh-sf.com/yui/
This is not possible. The browser needs to see it. Thus, the user is able to see it too.
There are methods you could use like obfuscating, disabling right clicks, etc., but these only work to prevent a small number of users from viewing it.
You can not hide the source html / javascript as they are run on client. You can obfuscate at max still one would be able to get to the source.
Yo'll have to switch to some kind of compiled application, like one in C++ instead of web application if you want to avoid people reading your sources.
I have searched this web looking for an answer, but it seems that this time I'm not so lucky, so I am forced to ask. I apologize if it's already answered (could not find it). And yes, English is not my first language, so I also apologize for my spelling mistakes, I try my best.
This is my problem, using Tomcat 5.5, Struts 1.3, JRE 1.5 and I'm using firefox 3.5.6.
In my jsp page I cannot seem to put any src="path/path" in my <script> I have tried deleting the src and all works well, but my project is going to need a lot of use from jquery and I do not want to copy/paste all the js file in every jsp.
This is my code:
<script type="text/javascript" src="js/jquery-1.3.2.js">
function showMySelf(){
alert("Hello World!");
}
(... plus other stuff code that actually uses jquery functions)
</script>
and the submit button:
<input type="submit" onclick="showMySelf()">
When I click the button, nothing happens (well it actually repaints the page) and when I delete the "src" tag from the script and add all the jquery code to the page it all works well.
I have tried putting another slash in the path as "/js/jquery-1.3.2.js" and returns an error.
I have tried using ResolveURL and it doesn't seem to give me better results.
I have also tried changing the js file to another file ("generics.js" and "js.js"), I also tried with "js/*.js".
Any of theese solutions have archived anything.
I have also tried using the struts tags (like html:submit) but it also did not work.
The path is actually right, since looking the code in my web browser gives me a link to the js file. So I suposse the browser knows were to look for my js file, it does not give me an error or a broken link to the file.
Any ideas of why this is happening?
Thank you all.
Random.
You can not use a script element to load an external file and put code in it at the same time. You need to use two script elements:
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
function showMySelf(){
alert("Hello World!");
}
(... plus other stuff code that actually uses jquery functions)
</script>
I think Gumbo solved it.
As a sidenote, a very good way to find out whether a browser can load a JS file is the "Net tab" in Firebug in Firefox. It shows all loaded (and failed) requests of the current page.
The two most likely options are:
a) You are including HTML in your JS file (i.e. <script> tags)
Take it out.
b) You have the wrong URI and when you attempt to resolve your relative URI manually you do so incorrectly
Look at your server access logs to see what is actually being requested (or use a tool such as Firebug)
The first thing to do in such case. Install Firebug and look at the "Console" panel (for possible syntax errors) and the "Net" panel to see whether your jQuery sources are being fetched correctly. The 2nd column there shows the request status code.
alt text http://img46.imageshack.us/img46/6224/jqueryfirebugtmp.jpg
(full size image)