jQuery doesn’t load in Firefox

Hello all,

Last day I had a problem with jQuery and Firefox. I had to create a drop-down menu and it worked perfectly fine in Safari and IE but not in Firefox.

My code looked like this:

<script type=”text/javascript” src=”js/jquery-1.4.4.min.js”/>
<script>

//some jQuery code

</script>

The problem is that Firefox wants <script type=”text/javascript” src=”js/jquery-1.4.4.min.js”></script> and not <script type=”text/javascript” src=”js/jquery-1.4.4.min.js”/>.

Hope this helps,

Andrei

Advertisements

CodeIgniter datepicker with JQuery

Hello all,

 

First of all I want to thank all my viewers from the previous post and I hope that post helped them as much as possible.

 

I am currently developing a web application using CodeIgniter. It is a great framework and everything is very well documented and well thought. But nothing is perfect on this world so I found that creating a date picker using JQuery and CodeIgniter could be very painful especially if you are quite new with both these technologies. So let me first explain how you should proceed and make everything work great.

 

1. Download CodeIgniter from their website. You will receive a folder called CodeIgniter_1.7.3 with everything you need in it. Create a folder called assets underneath CodeIgniter_1.7.3 and under assets create 3 folders: css, images, js.

2. Download JQuery and JQuery UI from their website and place jquery-1.4.4.min.js and jquery-ui-1.8.8.custom.min.js under the js folder created above. When you download JQuery UI you will see that under their css folder they have a folder called ui-lightness. Place this one under you css folder created above.

3.  In CodeIgniter_1.7.3/system/application/config you must edit config.php file like this:

$config[‘base_url’] = “http://&#8221;.$_SERVER[‘HTTP_HOST’].”/CodeIgniter_1.7.3″;

This will set your base url to you root folder.

4. Finally lets create the view. Under the  CodeIgniter_1.7.3/system/application/views create a new view. Let’s call it test.php. Edit it as it follows:

 

<html>

<head>

<title>test</title>

<script src=”<?=base_url()?>/assets/js/jquery-1.4.4.min.js” type=”text/javascript”></script>

<script src=”<?=base_url()?>/assets/js/jquery-ui-1.8.8.custom.min.js” type=”text/javascript”></script>

</head>

<body>

<script>

$(document).ready(function() { $(“test”).datepicker(); });

</script>

<form>

<input type=”text” id=”test” name=”test” />

</form>

</body>

</html>

 

So these are the 4 steps you need to follow in order to set up you JQuery running on you CodeIgniter platform. For the controller that will launch the view above you can watch lots of tutorials on CodeIgniter web site and also on YouTube.

Hope this helps.

Andrei.

itext 1.5 Html to Pdf

Hello all and Welcome to my first blog post,

I have recently ran into a big problem on how to use iText 1.5 in order to parse a HTML that was converted to a String into a pdf file. The project that I am working on is quite old and we are trying to migrate it from Java 1.4 to Java 6. With that being said we are also trying to use the latest versions on all our jars.

The old itext had also an itextXml library that used a SaxmyHtmlHandler class to handle the content and parsed the content using a SaxParser. So I begun researching for ways to rewrite SaxmyHtmlHandler with the new itext library since itextXml.jar wasn’t available for the new version. The documentation is very weak and lacks in giving the right examples. On the lowagie site the examples are useless since they write their on parsers for a very particular case not a general case like  SaxmyHtmlHandler treated.

After days of researching I had discovered HTMLWorker. I have seen it before in their lib but no examples were there to explain how should it be done properly. I will give you the code below.  It should be put in void main(String args[]) method. Hope this helps!

try {

com.itextpdf.text.Document document = new com.itextpdf.text.Document(PageSize.A4);
PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(“D://testpdf.pdf”));
document.open();
document.addAuthor(“Author of the Doc”);
document.addCreator(“Creator of the Doc”);
document.addSubject(“Subject of the Doc”);
document.addCreationDate();
document.addTitle(“This is the title”);

//SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
//SAXmyHtmlHandler shh = new SAXmyHtmlHandler(document);

HTMLWorker htmlWorker = new HTMLWorker(document);
String str = “<html><head><title>titlu</title></head><body><table><tr><td><p style=’font-size: 10pt; font-family: Times’>” +
“Cher Monsieur,</p><br><p align=’justify’ style=’text-indent: 2em; font-size: 10pt; font-family: Times’>” +
“asdasdasdsadas<br></p><p align=’justify’ style=’text-indent: 2em; font-size: 10pt; font-family: Times’>” +
“En vous remerciant &agrave; nouveau de la confiance que vous nous t&eacute;moignez,</p>” +
“<br><p style=’font-size: 10pt; font-family: Times’>Bien Cordialement,<br>” +
“<br>ADMINISTRATEUR ADMINISTRATEUR<br>Ligne directe : 04 42 91 52 10<br>Acadomia&reg; – ” +
“37 BD Aristide Briand  – 13100 Aix en Provence  </p></td></tr></table></body></html>”;
htmlWorker.parse(new StringReader(str));

document.close();

} catch(DocumentException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}