I have inherited a site and don't really understand the set-up!
The scripts on the site were all working ok then we are suddenly getting script errors and the script that entered a date in a field has stopped working.
this is at the top of the page:
<script type="text/javascript">
setURLs(//domainname/base/administration/);
</script>
I am getting this error: Unexpected end of input - what do I need to do to fix that?
Then this script:
<script>DateInput('Payment_Date', true, 'yyyy-mm-dd','2022-07-20')</script>
is giving the error DateInput is not defined and the field is not been added to the form - how do I sort that?
from the two lines of code that you shared I noticed a problem with
<script type="text/javascript">
setURLs(//domainname/base/administration/);
</script>
the // means comment so in order to make the function work you need to add some ' around it
like this
<script type="text/javascript">
setURLs('//domainname/base/administration/');
</script>
Related
This is a question from a noob in javascript. I tried to find something similar the last two days but I didn't find. I try to pass an html image element to an external javascript file which I include to the rest html code. The javascript fade in and fade out an image. Because I want to use different images everytime, thus I want to have a function in an external javascript file.
What I did so far:
PHP and HTML:
<?php
if ($success){
echo"<link rel='stylesheet' href='js/jquery-ui-1.11.4-smoothness.css'>
<script src='js/jquery-1.11.3.js'></script>
<script src='js/jquery-ui-1.11.4.js'></script>
<img id='tick' src='tick.png'>
<script type='text/javascript' src='js/success_failure_signs.js'>
success_failure(tick);
</script>";
}?>
Javascript file has this code:
function success_failure(tick){
var x = tick;
x.fadeIn();
x.fadeOut(1000);
}
The browser's console doesn't give any error.
It seems that the function success_failure doesn't get the image.
What is wrong on this code and how can I fix it?
Thank you in advance!
You haven't defined tick when you make your function call. Try this...
<script type="text/javascript" src="js/success_failure_signs.js">
</script>
<script type="text/javascript">
var tick = $("#tick");
success_failure(tick);
</script>
EDIT: I've also separated the inclusion of the script and your code to call it into two separate script tags.
maybe passing the image to the script is the wrong way of thinking here.
Most of the time with Javascript for web pages the JS gets the image from the HTML site itself.
You are already including jQuery so look into how to get an element from the page with jQuery.
I am facing a problem that I am not able to solve since few days.... The problem is that when I hardcode HTML tags with values the page is getting loaded with no issues....but while try to load data dynamically by parsing rss feed and then using append to insert the data in the main tag it's not working.... I tried tracing the output of the java script by using alert fucntioin and the output is the extact html that is required...
My code was working fine until I added
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">google.load("jquery", "1");</script>
I am also calling jquery 1.10.2 at bottom of the page referring to lots of other js
The code is as below:
<div id="grid">
<script>
myFunction('test');
</script>
</div>
Fucntion:
function myFunction(var1) {
$('html').removeClass('no-js');
if ($.browser.safari || $.browser.webkit) {
$('grid').addClass('webkit');
}
$('#grid').facebook_wall({
id: var1,
access_token: '193673707489176|55a9bc60f1b35074263ea95e45218fc3',
limit: 1
});
};
</script>
Please help I am not able to trace it....
Don't need semi colon after function myFunction (){ }
I just added CKEditor to my website, but I'm getting the following error in my console:
I followed the installation guide as it's written so I have no idea what's wrong.
Here's, briefly, what my call looks like:
<textarea id="full-editor" name="full-editor" rows="10" columns="6"></textarea>
<script type="text/javascript">
CKEDITOR.replace('#full-editor');
</script>
Aah.. try this
Remove # from the selector inside CKEDITOR.replace('#full-editor');
According to installation guide you shared, this is what u need
CKEDITOR.replace('full-editor'); // NO #. You must have got confused with jQuery
This also happened whenever we put initializer script before <textarea>.
Ensure to put
<script>
CKEDITOR.replace( 'editor1' );
</script>
before the </body> tag (i.e. closing body tag).
<script type="text/javascript">
CKEDITOR.replace('#full-editor');
</script>
Please add above code in external js file and include this js in html page after title page like
$(document).ready(function () {// save as like ckEditorInclude.js
CKEDITOR.replace('#full-editor');
}
<script src="Your folder path/ckEditorInclude.js" type="text/javascript"></script>
This also happened whenever we put initializer script before .
Ensure to put
CKEDITOR.replace( 'editor1' );
before the </body> tag (i.e. closing body tag).
This append to me because i was trying to use CKEDITOR.replace("editor") but there was no element in dom with Id or name "editor"
The issue for me was I copied the code locally from the cdn so that I can work on it if I am not online. I am using version 4.9.2 standard.
Examining the chrome console gave several 404 errors which were not obvious using FireFox. Reverting back to the cdn resolved the issue.
Unfortunately, no working offline with this it seems at least not for this version of ckeditor.
I have included moment.min.js in my page
<script src="js/jquery.js"></script>
<script src="js/modernizr.js"></script>
<script src="js/moment.min.js"></script>
<script src="js/fatcalc.js"></script>
I can call
<script>document.write(moment());</script>
and it displays the date fine on my page.
But, when I call it from within fatcalc.js
var date = moment();
I get the error:
'moment' is not defined.
Why can my html page see it, but not the fatcalc.js file?
Well, I figured it out. Seems to be some issue with Jshint I don't understand but adding this to the top of my script fixed it.
/*global moment:true */
My main page is index.php. I'm loading a section of the page with AJAX and I would like to also load a datepicker in the same section I got all relevant JS:
<script type="text/javascript" src="javascripts/jquery/jquery.js"></script>
<script type="text/javascript" src="javascripts/datepicker/jquery.datePicker.js"></script>
<script type="text/javascript" src="javascripts/datepicker/date.js"></script>
I hope i'm not missing anything, the CSS is copied into my main css file.
and here's how the ajax looks like, at least the callback part:
xmlhttp12.onreadystatechange=function() {
if (xmlhttp12.readyState == 4) {
if(document.getElementById("corpcrm").innerHTML=raspuns[0]){
$(function()
{
$('#datepicker')
.datePicker({inline:true})
});
Now i know there aren't any problems with the the rest of the code as i've been using the very same thing for a while now, somehow I can't get the jQuery part right.
i tried adding a div directly to index.html and adding
<script type="text/javascript">
$(document).ready(function(){
$("#test").datepicker();
});
</script>
in the head. Firebug finds an error related to it that says
$('#test').datepicker() is not a function
The problem is now solved. I wasn't loading jquery-ui properly, was missing a > at the end of a script, thanks for the help guys.