Dynamically add ckeditor textarea using javascript

CKEditor textarea add dynamic using javascript

CKEditor textarea add dynamic using javascript

Are you looking for the solution of the following questions than here is the solution to add dynamic CKEditor textarea.

How to add CKEditor Textarea runtime using javascript?
How to add CKEditor Textarea Dynamically using javascript?
How to add CKEditor Textarea runtime using jQuery?
How to add CKEditor Textarea Dynamically using jQuery?
CKEditor textarea add dynamic using javascript.

When you are working with CMS or webpage where you need the functionality to do “Add More” which will add new textbox, checkbox, radio button or select dropdown than you can do it easily. Even you can add simple textarea as well with normal code but when you need to insert CKEditor at runtime than may be you stuck.

I am here to help you, Simple code to add CKEditor textarea dynamically at runtime without refresh the page. You can use this code to add CKEditor textarea at runtime.

 
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
 <script type="text/javascript" src="../includes/ckeditor/ckeditor.js"></script>
 <script src="../includes/ckeditor/adapters/jquery.js"></script>
 
 var counter = 1;
 
 function AddMoreTextEditor()
 {
   var newtxtname = 'txtNew' + counter;
   var newTextArea = '<textarea rows="10" cols="50" class="ckeditor" name="' + newtxtname + '" id="' + newtxtname + '"></textarea>';
   $("#divid").html(newTextArea);
   $('textarea#' + newtxtname).ckeditor();
   counter++;
 }

please set “#divid” which is the placeholder here. You need to set the path of “ckeditor.js” and “jquery.js” as per your project. In above javascript code there is a function named “AddMoreTextEditor” to add new CKEditor textarea. Call this function from your “Add More” Link.

Please let me know if you need more help.

Incoming search terms:

  • add ckteditor to textbox

How to know browsing mobile device or identify mobile device using javascript or jquery

 

If you have below question in your mind than this article is very helpful for you.

How to know that web-site open in mobile device or in computer?
Can I run some specific code when its open in mobile device only?
How to know browsing mobile device or identify mobile device using javascript or jquery?

Its long time but I went to Malaysia for my vacation, which is really an awesome country and enjoy lots in Malaysia, having very good experience in Malaysian airline(but thank god that i did not travel in missing Malaysian aircraft MH370) and top tourist places in Malaysia. If you planning to visit Malaysia than definatily visit top 10 tourist places of Malaysia which is Cameron Highlands, Georgetown Inner City, Taman Negara, Pulau Tioman, Mount Kinabalu, Petronas Twin Towers, Langkawi, Perhentian Islands, Sepilok Rehabilition Centre, Mulu Caves and Genting Highland

Now, let’s come to the topic of mobile device and web-site issue, recently I am working on the web-site where we have one page with the apps, this page include description and hyperlink of android apps for android devices, apple apps for iphone and ipads. For navigation on this page there is one nice icon in footer menu of my web-site. This is working fine with the web-site. But my client needs to do something new, so when user click on this link and its android device or ios device than its not open the apps page but bring you directly to the apps store, and user can directly install apps from apps store. To implement this we need to know the user’s device and as per that we need to set the link.

var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
 
if(isMobile.Android())
{
   // Your Code
}
 
if(isMobile. iOS ())
{
   // Your Code
}

Above javascript code is useful to know that user browsing from mobile device or from the computer. its also useful to know that which mobile device is used for browsing the web-site. Please let me know if you have any question regarding the browsing device and compatibility of browsers and all mobile devices.

Open external links in new tab or open external links in new window automatically using jquery

 

How to open external links in new tab or how to open external links in new window automatically using jquery?

Today, when I am working with the link building for my blog than suddenly one new thought come in my mind that when we include external links in our web-site, and readers redirect on those links from our web-site. This way we can loose the readers from our web-site and may be they will not come back from that.

One way to keep the readers on our web-site is to open all the external links in new tabs. Or open all the external links in new windows. This means open external link in separate tab or open external link in separate window.
There are two way to fix this issue, either you can do it automatically using the jquery or you can give target _blank in all <a> tags in the content of each web page as well as all the links in your website navigation.

I don’t think that I need to explain regarding how to open external links in new tab or how to open external links in new window in <a> tag.
You can do it automatically using jquery code which is as below.

//Open external links in new tab or open external links in new window automatically using jquery
 
$(function($){
    $('a[href^="http://"]')
        .not('[href*="freelancephpdevelopment.com "]')
        .attr('target','_blank');
});

You need to add this code in your page in script tags, make sure that you change the domain name or url which is “freelancephpdevelopment.com” in this code with your domain name or url. Please let me know if you need more help to fix this type of issues.

how to call two javascript function onload event

When you working with the php and javascript then you get below question in mind when you stuck.

How to call two function onload event?
how to call more then one function when page load?
how to call two javascript function when page load?

Some time we need to call more then one javascript function when the page load, most of programmer make mistake and they call one function using onload body tag and another one using window.load = function name. when you do like this then its call only one function and another one will not call.

to get proper result we need to use any one method from below three methods.

 
1) &lt;body onload="phpfreelancer();hirephpprogrammer();phpfreelancerindia();"&gt;

Here, you can call all function using the onload event of body tag.

 
2) function loadonstart()
{
phpfreelancer();
hirephpprogrammer();
phpfreelancerindia();
}
 
window.onload = loadonstart();

Here, you call one function on window load event and in that function you can call other function.

 
3)   window.onload = phpfreelancer();
window.onload = hirephpprogrammer();
window.onload = phpfreelancerindia();

Here, you call all three function using separate code.

I Hope this will resolve you problem if not then you can contact me any time.

 

countdown timer using javascript

How to implement countdown timer using javascript?

Today i am working with one of the most important project and in this we need a timer countdown, if you look on the auction web-site then they show the time remaining to close the auction of the item, in that the time is working and its show on the page. this type of timer we can easily implement using the JavaScript.  here i share my code with you guys so you can not waste your time to implement this and use my code directly in your web site.

<table width=”100%” border=”0″ align=”center”>
<tr>
<td align=”center” id=”displaytimerdays”>00</td>
<td align=”center” id=”displaytimerhh”>00</td>
<td align=”center” id=”displaytimermm”>00</td>
<td align=”center” id=”displaytimerss”>00</td>
</tr>
</table>
<script language=”JavaScript”>
var TotalSeconds = 100;

function InitializeTimer(TimeInSeconds) {
TotalSeconds = TimeInSeconds;

SetUpdateTimer();
window.setTimeout(“StartTickTick()”, 1000);
}

function StartTickTick() {
TotalSeconds -= 1;
SetUpdateTimer();
window.setTimeout(“StartTickTick()”, 1000);
}

function SetUpdateTimer() {
var Seconds = TotalSeconds;

var Days = Math.floor(Seconds / 86400);
Seconds -= Days * 86400;

var Hours = Math.floor(Seconds / 3600);
Seconds -= Hours * (3600);

var Minutes = Math.floor(Seconds / 60);
Seconds -= Minutes * (60);

document.getElementById(“displaytimerdays”).innerHTML = LeadingZero(Days);
document.getElementById(“displaytimerhh”).innerHTML = LeadingZero(Hours);
document.getElementById(“displaytimermm”).innerHTML = LeadingZero(Minutes);
document.getElementById(“displaytimerss”).innerHTML = LeadingZero(Seconds);

}
function LeadingZero(STR) {

return (parseInt(STR) < 10) ? “0” + STR : + STR;

}
window.onload = InitializeTimer(5000);
</script>

Here, window.onload = IntialiseTimer(5000); function initialize the timer function and then its start the countdown. please let me know if you have any difficulties to implement this in your site.

set cross-subdomain cookie with javascript

How to set cross-subdomain cookie with javascript?

As we mention that using php we can set the cookie for cross-subdomain, we can also set the cookie in javascript as well. when we are working on the sub-domain and we need cross-subdomain cookie in php then we also need cross-subdomain cookie in javascript.

First i explain how to set cookie in the javascript because people are not aware that we how to set cookie in javascript. using JavaScript, you can create cookie and retrieve value from that cookie.

document.cookie = ‘cookiename=’ + cookievalue+ ‘,expires=’ + expirydate.toGMTString();

Here cookiename is the name of cookie and the cookievalue is the value which you need to store in the cookie, expires is the expiry data of the cookie.

Now, if you need to set cross-subdomain cookie then use the below code

document.cookie = name+”=”+value+”expires=”+date.toGMTString()+”; path=/;domain=.example.com”;

Here i mention 2 more things which is not available in the first one, this is path and domain. path is the folder path where you need to store the cookie and the domain is the domain name for which you need to set the cookie, please look carefully that i set .example.com value in the domain, here first dot(.) is required if you want to set it for cross- subdomain, if you do not set it then it will not work for cross-subdomain.

What is JavaScript and JQuery?

JavaScript is scripting language based on the prototype, JavaScript is not related with Java. Java is different programming language.

JavaScript is used in web-application, almost all the web based application use javascript as scripting language. there is one another scripting language known as vbscript, basically this scripting language is used in desktop application. you can also use javascript in the desktop application.

Next version of the javascript is the JQuery, JQuery is very big library and you get easy solution using it, you get very good effects when you use JQuery. you can use object oriented programming in javascript as well. so you create the class in the javascript and create the object and use it through out the application.