<script type=”text/javascript”>
jQuery(document).ready(function() {
if ($(“#divId”).length > 0){
// your code here
}
});
</scrip
Tag Archives: Javascript
jQuery
jQuery is a multi-browser JavaScript library designed to simplify the client-side scripting of HTML. It was released in January 2006 at BarCamp NYC by John Resig. Used by over 55% of the 10,000 most visited websites, jQuery is the most popular JavaScript library in use today
jquery conflict
<script type=”text/javascript”>
jQuery.noConflict();
jQuery(document).ready(function() {
// Your code comes here
});
</script>
Check if a string exists javascript
<script type=”text/javascript”>
if(window.location.href.indexOf(“https:”) > -1) {
alert(“its a secure URL”);
}
</script>
Replace a string javascript
<script type=”text/javascript”>
var string=”PHPCode”;
string=string.replace(“Code”,”Codez”);
alert(string);
</script>
JSON Object Notation
- A JSON object is an unordered set of name/value pairs
- A JSON object begins with { (left brace) and ends with } (right brace)
- Each name is followed by : (colon) and the name/value pairs are separated by , (comma)
Why Use JSON over XML
- Lighter and faster than XML as on-the-wire data format
- JSON objects are typed while XML data is typeless
- Native data form for JavaScript code
JSON
JSON or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects. Despite its relationship to JavaScript, it is language-independent, with parsers available for many languages.
A format to represent any PHP type, except a resource, that can be used later in JavaScript
The JSON format was originally specified by Douglas Crockford, and is described in RFC 4627. The official Internet media type for JSON is application/json. The JSON filename extension is .json.
Print a Web Page Using JavaScript
<a href=”javascript:window.print()”>Print</a>
Check javascript is enabled in the browser + php
<noscript>Please enable Javascript</noscript>