Part of jQuery code missing? - javascript

I am using colorbox which I have used many times for different clients, but it is not working this time and I can not figure out why. I am trying to open a video on YouTube, and then open up some inline HTML, I've copied the code from the examples just as I always do, and replaced what needs to be replaced. There are parts of the script that are missing when I look at the source code from the browser. The website is http://www.powerhousebowling.com. Maybe I'm missing something.
In my backend it looks like this:
<script type="text/javascript">
$(document).ready(function(){
$(".youtube").colorbox({iframe:true, innerWidth:425, innerHeight:344});
$(".open_colorbox").colorbox({width:"50%", inline:true, href:"#inline_text"});
});
</script>
But when I look at the source code in FF or IE it shows...
<script type="text/javascript">
$(document).ready(function(){
$(".youtube").colorbox();
$(".open_colorbox").colorbox();
});
</script>

If the code you are mentioning is inputed in some kind of backend, the software or the server is probably striping the code for security reason. See what happens if you remove de curly brackets and if the code appears then try finding how to insert them following the software's rules ({literal}{/literal} if it is a Smarty template)

I finally found out what was happening about a week ago, sorry for the delay in answering, I was out of the office. The CMS that we use, ExpressionEngine, was thinking anything between the curly brackets were tags for itself, I took the script outside the CMS and pointed to it, works fine! Hope this helps anyone else!

Related

Javascript didn't load in my html

So i copy the codes from this website completely unchanged
-> enter code herehttp://jsfiddle.net/laelitenetwork/puJ6G/
But the button doesn't work for me. When i click the + and -, nothing happen to the number.
This is my code in the netbeans.
Is my netbean problem or something missing in the javascript?
the html, css and javascript
I am not entirely sure on what exactly you are asking but I understood it like that:
You want to use the code from the JSFiddle in your own project and it does not work.
If that is the case, I think you forgot to add a reference to JQuery in your code.
Add this to your HTML:
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
And see if that fixes your problem.
However if it does not fix it, please edit your post with the full code.

Mediawiki widget will not run javascript

I am having a ridiculous problem which seems to be a lot harder than it really should be.
Have been struggling now for about three days trying to figure out a way to run javascript on pages in wikipedia, and it seems like it is close to impossible. (I can get it to run under common.js, but want it only on specific pages.
Seemed like one option is to use Widgets, but whenever I put script in, mediawiki changes it and removes the <> (changes it to &lt and &gt), which means it will not run, and I can't find a single mentioning anywhere how to get Mediawiki to stop doing this for Mediawiki or for the Widget extension. Any help would be welcome.
As an example, I put the following code in widget:redbox
<noinclude>
This is a test
</noinclude>
<includeonly><script> type="text/javascript"> console.log("I am alie"); </script></includeonly>
And what I get back is
This is a test fckLR <script> type="text/javascript"> console.log("I am alie"); </script>fckLR
The simplest solution is to put a script in common.js that will only run if an element with a certain ID exists on the page (i.e. $( '#some-id' ).length > 0).
Since nobody pointed out what I'm about to say, I am probably missing something... Also I know this post is very old, but is there a reason for type=text/javascript not to be inside the opening script tag?
I really fail to see why placing attributes outside the opening tag could be useful.
Just in case this was really a mistake and that's all there is to it, the correct syntax would be
<includeonly>
<script type="text/javascript">
console.log("Hello, underworld!");
</script>
</includeonly>

How do I see error messages for JavaScript/JQuery code in IE?

I am new to javascript and have been working overnight to see how I can fix this error on IE: Here's the question I asked here yesterday: How to fix this jquery function to work in IE?
After spending more than 20 hours I still can't find out why it wouldn't render parts of my page properly.
At the very least I thought I could find a way to get the errors so I can fix them or do a separate javascript file just for IE, but no luck.
How do I see error messages for my script?
I used F12 to see the developer console but no help there, it won't even tell me what's wrong.
I am using IE 8 and 9.
I know that there could be many things wrong with this and I appreciate your patience in advance for helping me out. Thanks!
You have invalid HTML including many invisible characters within the head section which is also blocking the W3C HTML Validator from getting past the first few errors.
When I copied your source code into my text editor, I found a bunch of invalid invisible characters. Did you cut/paste your JavaScript from someplace like a web-page? The invisibles only appear in front of your custom written scripts in the <head> and nowhere else. This could certainly explain a lot, including the validation error about a misplaced </head> tag. Go back to your editor and delete the indentations on every single line within the entire <head></head> section, then re-indent each line from scratch.
I also see an invalid closing tag, </label6>.
Remove the invisible characters, fix the invalid HTML, and see what IE does.
Moving forward, get yourself a powerful text editor that will allow you to see invisible characters so you can delete them and properly indent as needed. Otherwise, I recommend re-typing your code rather than cutting & pasting.
For JavaScript errors, the best is to see the 'Console' tab for records.
If IE's one isn't showing anything, maybe you could try using FireBug Lite, adding the following script after <head> (YES, put it as first thing, so it loads first than anything else).
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>
On side note, maybe isn't a JS problem and yes something about running code locally. IE has some policies that mostly block client-side code from running. (Remember those annoying ActiveX prompts?). Check Intranet configuration on Settings.

Has Chrome browser broken dynamic script loading?

This isn't my code, I'm just troubleshooting it. Some code that has been working for over a year has now stopped working in Chrome (12.0.742.122), but works in the other "big" browsers (including fellow WebKit stablemate Safari (5.0.5)). By "not working anymore" I mean that although the script file does load, it doesn't execute. The kind of behaviour you'd expect if loading a script into innerHTML or writing it into a div, but neither of which things are being done. The commented-out lines below were all failed attempts at getting it working, the first of those being the original code that had worked up until recently.
<div id="abc"></div>
<script type="text/javascript">
var d=document.getElementById("abc");
var s=document.createElement('SCRIPT');
if(s){s.src=script_path;}
//if(d)d.appendChild(s); //original line that still works in all other browsers
//if(d)d.parentNode.appendChild(s);
//if(d)d.parentNode.insertBefore(s,d);
//if(d)d.parentNode.insertBefore(s,d.nextSibling);
document.body.appendChild(s); //this works, script executes
</script>
What is wanted from this code above, is that the script is a child of the div. Presumably they want to be able to remove that child and have all script be removed at the same time (I'm not sure of their motivation).
I've discovered what the problem was, largely thanks to Martin Bieder's back and forth and introducing me to jsfiddle.net with his working example.
The issue was actually the test page and what you'd think would be a fairly harmless error they made in creating it. The div and all of the code will be represented below simply as ######, as it's not even relevant to the problem. It's actually a HTML problem. Chrome 12 isn't happy if you don't match up your closing tags properly. I really can't believe that it has an effect on the execution on script files, but it does. I've tried many many times in the last 10 minutes with the HTML tags right and wrong and unbelievably this really is the problem.
<font><center><b>
##########
</b></font></center>
You see how the font and center closing tags are the wrong way around, and that's enough to confuse Chrome sufficiently that it won't execute any dynamic script being added within those tags. Bizarre. I can't recreate this on jsfiddle, probably due to the nature of the site runs the html/js that you put onto it (using onload for example).
No it works. Google Analytics uses is, too.
var ga=document.createElement('script');
ga.type='text/javascript';
ga.async=true;
ga.src='http://www.google-analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga,s);
Have you tried to set to async the script element?
var script = document.createElement('script');
script.async = 'async';
It is all about 3 things.. Organization, Optimization, and debugging.
1)properly scoping your tags makes things easier to read.
2)properly organizing your code makes it easier to parse which means parsers can be faster and more efficient.
3)alot of the debug tools we use rely on this organization in order to display things like collapsible tags and present a more visual scoping

DOM based scripting

ok so here's my problem...
i've been following this tutorial ( http://www.alistapart.com/articles/dropdowns )
to make a css drop down menu with my wordpress blog. everything works fine... except in IE6.
now i know this is normal, and in the link i posted above there is a fix of this which makes use of DOM based scripting... is this java script?
the main question i have is.. where do i paste this code into? css, html, make a new file?
i'm new to any form of javascript.. it's boggling me a bit..
any help would be great!
Thanks!
yours truly
noobie
Yes, it is JavaScript.
As such, you can place it in a <script> block, preferrably inside <head>. (It assigns itself to window.onload, so the code will be executed at onload, no matter where in the page you put the code)
the main question i have is.. where do i paste this code into? css, html, make a new file?
I suggest you take a look at the source of this sample page:
http://www.htmldog.com/articles/suckerfish/bones/. It shows the bare details of how it's implemented.
i'm new to any form of javascript.. it's boggling me a bit..
I would like to suggest you read this nice tutorial which already helped out numerous developers during the years: w3schools.com/js.
Grz, Kris.

Categories