Javascript question - JavaScript Help


I just wanna ask, i have used lots of javascript function in one of my page and i found the size of it is over 1 MB, i dont have any idea on how to reduce the size of it as all code is necessary.....how long will it take to open this huge size of page.

Thx
Posted On: Wednesday 2nd of January 2013 12:39:36 AM Total Views:  341
View Complete with Replies

RELATED TOPICS OF JavaScript PROGRAMMING LANGUAGE




Allow links to open in new window with on/off feature? - JavaScript Help

, could anyone please provide me with a working example of a javascript that detects all of the active urls on the page and opens them in another window but has the option of opening all links normally (without target="_blank"). So someone can click a link to disable links opening in a new window, but on default they will open in a new window. Could you please provide a working example\t
VIEWS ON THIS POST

160

Posted on:

Tuesday 27th November 2012
View Replies!

add textbox and drop down list - JavaScript Help

Hi all,I have a problem with javascript.Script must add text box and select box(with values from database) when click on Add element.The script work fine without select box but I need textbox and select box.db.php-is settings for connection on databasesql.text-is mysql data tableHelp me please.[attachment deleted by admin]
VIEWS ON THIS POST

160

Posted on:

Tuesday 27th November 2012
View Replies!

onclick from div not working in IE (with execCommand) - JavaScript Help

I'm working on some rich text editing techniques to be applied in a larger project. The following code works great in firefox and ok in ie when i am triggering the onclick from a but not a this makes little sensse to be...especially because if i stick an alert(); function into the js (doRichEditCommand() function) it outputs to the browser ...but the execCommand doesn't...at least not by cllicking the .\tNote: clicking a to trigger the event does work in ie function Init() { getIFrameDocument("editorWindow").designMode = "On"; } function getIFrameDocument(aID){ // if contentDocument exists, W3C compliant (Mozilla) if (document.getElementById(aID).contentDocument){ return document.getElementById(aID).contentDocument; } else {// IE return document.frames[aID].document; } } function doRichEditCommand(aName, aArg){ if (window.getSelection) { //ff getIFrameDocument('editorWindow').execCommand(aName,false, aArg); document.getElementById('editorWindow').contentwindow.focus() } else if (document.selection) { // ie //alert('broken'); editorwindow.document.execCommand(aName,false, aArg); } } Red Blue
VIEWS ON THIS POST

175

Posted on:

Tuesday 27th November 2012
View Replies!

Problem in this Code

when i click plus ( + ) and minus ( - ) is not working.. AMF / Aldric's #popupbox { margin: 0; margin-left: 40%; margin-right: 40%; margin-top: 120px; padding-top: 10px; width: 25%; height: 180px; position: fixed; background: #660066; color: #00FF00; border: solid #000000 2px; z-index: 9; font-family: arial; visibility: hidden; } var products = new Array ("lapis","tite","manok"); var list = new Array; var add = new Array; var sub = new Array; var ctr = 0; var bilang=0; document.oform.quantity.value=bilang; function compute(ope) { if(ope == "add") { bilang+=1; document.oform.quantity.value=bilang; } else if(ope == "sub") { if (bilang == 0) { document.oform.quantity.value=0; } else{ bilang -=1; document.oform.quantity.value=bilang; } } } function show_gamecards() { document.getElementById('gamecards').style.visibility = "visible"; } function hide_gamecards() { document.getElementById('gamecards').style.visibility = "hidden"; } PRODUCTS WHAT'S NEW ABOUT US DEVELOPERS PRODUCTS: School Supplies Toys Fassion Accessories Cellphone Accessories Game Cards Game Cards Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price
VIEWS ON THIS POST

143

Posted on:

Thursday 29th November 2012
View Replies!

Javascript innerText Span issue

I'm quite new to javascript, but not at all new to programming. I've been working on an extension in google chrome and I've run into a rather odd problem. Basically I have an html snippet that looks like this Total Questions: Answers Found: Click here to load questions There are two possible states, in one I want the whole QuestionsAnswers div to be hidden and the ClickToLoad to be visible, and in the other I want QuestionsAnswer to be visible and the two spans (questionNumber, answerNumber) to contain the releveant numbers, and ClickToLoad to be hidden. I tried to implement that like this: function AppropriateVisual() { if (!localStorage.QuestionList) { document.getElementById('ClickToLoad').style.display="inline"; document.getElementById('QuestionsAnswers').style.display="none"; } else { document.getElementById('ClickToLoad').style.display="hide"; document.getElementById('QuestionsAnswers').style.display="inline"; document.getElementById('questionNumber').innerText=localStorage.QuestionList.length; if (localStorage.AnswerList) document.getElementById('answerNumber').innerText=localStorage.AnswerList.length; else document.getElementById('answerNumber').innerText="0"; //error here } } The first part works. If there is no QuestionList then only the appropriate elements are shown. However if the reverse is true, both QuestionsAnswers and ClickToLoad are shown. Weirder, the browser reports an error at the marked line saying answerNumber doesn't exist. Furthermore, inspection of the elements on the page show that whenever I set the inner text of questionNumber, answerNumber ceases to exist. What terrible thing have I done
VIEWS ON THIS POST

171

Posted on:

Thursday 29th November 2012
View Replies!

First and last name with last name alphabetized in javascript.

I have tried to find the answer. I have been asked to document.write my array by first name, then last name. However, I am being asked to alphabetize the list by the last name. I am pretty sure this involves a substring. I have been all over the internet trying to learn a method to do this. Yes, this is for a class but I am just asking that you point me in the right direction.
VIEWS ON THIS POST

165

Posted on:

Thursday 29th November 2012
View Replies!

How do I combine these two form validation scripts?

Hi I have the following script which works nicely: $(document).ready(function()//When the dom is ready { $("#MembershipNo").change(function() { //if theres a change in the MembershipNo textbox var MembershipNo = $("#MembershipNo").val();//Get the value in the MembershipNo textbox if(MembershipNo.length == 7)//if the lenght greater than 3 characters { $("#availability_status").html(' Checking availability...'); //Add a loading image in the span id="availability_status" $.ajax({ //Make the Ajax Request type: "POST", url: "ajax_check_MembershipNo.php", //file name data: "MembershipNo="+ MembershipNo, //data success: function(server_response){ $("#availability_status").ajaxComplete(function(event, request){ if(server_response == '0')//if ajax_check_MembershipNo.php return value "0" { $("#availability_status").html(' Available '); //add this image to the span with id "availability_status" } else if(server_response == '1')//if it returns "1" { $("#availability_status").html(' Not Available '); } }); } }); } else { $("#availability_status").html('MembershipNo is wrong length'); //if in case the MembershipNo is less than or equal 3 characters only } return false; }); }); But I need to check that the entry is numerical only so I found this bit of script: function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } But how do I combine them both so that it first checks it it numerical only and then checks the db for duplicates
VIEWS ON THIS POST

173

Posted on:

Thursday 29th November 2012
View Replies!

OutOfMemory Error Message

Hi to all experts. I am totally baffled by why I am geting an error message"OutOfMemory" and cannot seem to find a way around it or to reset the stack pointer. My codes is this: Untitled The ball image is here in a GIF file that I have attached. If anyone can tell me why it happens and what to do to get the ball to continue at the same speed several times Right to Left to Right again, I would be most appreciative. Attached image(s)
VIEWS ON THIS POST

138

Posted on:

Thursday 29th November 2012
View Replies!

Fun way to introduce yourself

I got a little bored today. Can you come up with an interesting way to introduce yourself using code Here is mine \t\tMe \t\t \t\t \t\t \t\t \t\t\t\tbody{background-color:Black;} \t\t\t\t#myAlert{background-color:White;padding-bottom:5px;} \t\t\t\th1{text-align:center;background-color:#EFEFEF;} \t\t\t\tp{padding:10px;} \t\t \t\t \t\t\t\tvarnewLine=""; \t\t\t\tvardeveloper={ \t\t\t\t\t\t\t\t\t\t\t\t\t\tfirstName:"E", \t\t\t\t\t\t\t\t\t\t\t\t\t\tlastName:"G", \t\t\t\t\t\t\t\t\t\t\t\t\t\temail:"Me@gmail.com", \t\t\t\t\t\t\t\t\t\t\t\t\t\tphone:"### ### ####", \t\t\t\t\t\t\t\t\t\t\t\t\t\tlanguageSpecialties:["C#","VB.net","ObjectiveC"], \t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabasesUsed:["MSSQL2008","MSSQL2005","MSSQL2000","MySQL"], \t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseSpecialties:["Storedprocedures"], \t\t\t\t\t\t\t\t\t\t\t\t\t\tfavoriteLanguage:function(){returnthis.languageSpecialties[0];}, \t\t\t\t\t\t\t\t\t\t\t\t\t\tfullName:function(){returnthis.firstName+""+this.lastName;}, \t\t\t\t\t\t\t\t\t\t\t\t\t\tlist:function(items){varvalues=""; $(items).each(function(idx,itm){ values+=itm+","; }); returnvalues.slice(0,-2); }, \t\t\t\t\t\t\t\t\t\t\t\t\t\tintroduceMySelf:function(){ \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvarresults=""; \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tresults=",mynameis"+this.fullName()+newLine+newLine; \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tresults+="Mylanguagespecialtiesare"+ this.list(this.languageSpecialties)+""; \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tresults+="butmyfavoritelanguageis:"+ this.favoriteLanguage()+newLine; \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tresults+="Ivedevelopedinthesedatabase,"+ this.list(this.databasesUsed)+newLine; \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\treturnresults; \t\t\t\t\t\t\t\t\t\t\t\t\t\t} \t\t\t\t\t\t\t\t\t\t\t\t}; \t\t\t\t$(document).ready(function(){ \t\t\t\t\t\tvarletMe=developer; \t\t\t\t\t\t$("#introBody").html(letMe.introduceMySelf()); \t\t\t\t\t\t$("#myAlert").show(); \t\t\t\t\t\t$("input").click(function(){$("#myAlert").hide();}); \t\t\t\t}); \t\t \t\t \t\t \t\t\t\t \t\t\t\t\t\t \t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\tIntroduction \t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t \t\t\t\t \t\t \t\t
VIEWS ON THIS POST

307

Posted on:

Thursday 29th November 2012
View Replies!

Add content to existing div

I have been trying to find an example of how-to add html text to an exisiting div and have had little success. The best I found so far was var pTag = document.createElement("p"); pTag.innerHTML = noBlanks[i]+" is a mandatory field."; ...
VIEWS ON THIS POST

223

Posted on:

Friday 30th November 2012
View Replies!

Basic questions about JS images

I thought JS was purely on client side. But if i do myImage.src = 'someImageOnServer.gif", it seems to work. How does JS do this Is a request sent to the server when this line of code is executed If yes, ...
VIEWS ON THIS POST

185

Posted on:

Friday 30th November 2012
View Replies!

Dynamically loading JS into iFrames - preventing IE7 popups whenleaving/entering secure connection

I have a webpage where Im creating AJAX type requests by loading dynamic pages containg JavaScript into hidden iFrames. The reason I am opting for this method over XmlHttpRequest object requests is because I wish for some of my ...
VIEWS ON THIS POST

131

Posted on:

Friday 30th November 2012
View Replies!

Don't understand these code.

Hi These code are part of Prototype. There are something that I don't understand, would you please explain it for me ....... toJSON: function(object) { var type = typeof object; switch (type) { case 'undefined': case 'function': case 'unknown': ...
VIEWS ON THIS POST

155

Posted on:

Friday 30th November 2012
View Replies!

Radio checking issue

Hi all How to check that "option A" is selected in the form i have something like this: javascript : ------------------------------------------- fnCheck(){ if(document.frm1.durationChange[0]=='...don't know what..........') { alert('selected A'); } } html -----------------------------------------------
option ...

VIEWS ON THIS POST

136

Posted on:

Friday 30th November 2012
View Replies!

Set focus to a div

Hi My users would like to be able to see the menu and the footer navigation in a website I'm building without first having to scroll to the top or bottom the screen in order to get to them, which ...
VIEWS ON THIS POST

173

Posted on:

Friday 30th November 2012
View Replies!

design pattern for jQuery dom.ready snippets

, I have tried posting this in the jQuery group with no response, and since it addresses a global design pattern, I'm wondering if someone can help me here.
VIEWS ON THIS POST

176

Posted on:

Friday 30th November 2012
View Replies!

Calling C# function from Javascript in ASP.NET

I'm trying to call a Server side function without AJAX in Javascript not VBScript, but I don't know who to pass as a parameter value that is in Javascript : Function blabla() { .... <% Pedro(VAL); %> .... } ...
VIEWS ON THIS POST

186

Posted on:

Friday 30th November 2012
View Replies!

check if radio is checked

David Mark wrote: >>> Best to use: >>> Or: >>> document.forms.myform.elements.owned_business[0].checked And this syntax is very readable once you become used to it. If one thoughtfully creates names (or id's) that reveal the context of the object, you will be ...
VIEWS ON THIS POST

97

Posted on:

Friday 30th November 2012
View Replies!

How to update a label using Javascript?

In my asp.net 2.0 web application, I would like to display the process progress information in the browser. The progress info is displayed one after another with 1 or 2 seconds delay in between them. I believe you have ...
VIEWS ON THIS POST

179

Posted on:

Friday 30th November 2012
View Replies!

Change the src of an Iframe.

Hi ! I have the HTML source like this: And I tried to change the source of the iframe like this: document.frames.Content_IF.location.href = 'iframe.php'; or like this: document.Content_IF.location.href = 'iframe.php'; These 2 ways ...
VIEWS ON THIS POST

125

Posted on:

Friday 30th November 2012
View Replies!

search script help!

I recently found this search engine script while searching the net recently and desperately need help with it. The script displays search hippo results via xml feed and the sponsored results on the right hand side are from revenue pilot. ...
VIEWS ON THIS POST

108

Posted on:

Friday 30th November 2012
View Replies!

Screen Size - Resolution - Mystery Print Preview

Hi , I am trying to write a preview page that will show a red box around the portion of the screen that would print on a normal 8.5x11 paper. The problem is setting the width of the div based ...
VIEWS ON THIS POST

129

Posted on:

Friday 30th November 2012
View Replies!

Trying to change a image dynamically

I am trying to change an image and it's associated width/ height dynamically via Javascript. In my HTML I have declared the following:
where largeImage is the ...

VIEWS ON THIS POST

187

Posted on:

Friday 30th November 2012
View Replies!

how to chain event callbacks

I want to add programmatically a function call to some onkeypress, taking into account that perhaps it already has something assigned. This addition is done on window load with the following code (it has some Prototype mixed in but it ...
VIEWS ON THIS POST

119

Posted on:

Friday 30th November 2012
View Replies!

re:How to show menus only if the mouse stays over it for a seco

In the onmouseover event, you use setTimeout() to trigger a function that actually does the popup. In onmouseout, you check to see if the timer is still active, if it is, you cancel the timer:
VIEWS ON THIS POST

170

Posted on:

Friday 30th November 2012
View Replies!

Table Generation

Any ideas why table generation is so much slower in IE using JScript than in Netscape using the same code and data. I'm trying to generate a long table from a dataset. My main target is IE but I always ...
VIEWS ON THIS POST

129

Posted on:

Friday 30th November 2012
View Replies!

Please help

I have this problem. I have copied this script on the net. The script changes font-size and color, starting from both ends until it reaches the middle, then it quickly displays another text string, letter by letter. The thing is ...
VIEWS ON THIS POST

160

Posted on:

Friday 30th November 2012
View Replies!

Create three javascript/jquery scripts into one script

I have three javascript/jquery scripts and I need all of them. I am new in jquery so not able to add all three scripts. If I do all then one of them do not work. I need to put all three scripts into one. $(function(){ // off $("#pgfor").twoitems({ header: false }); // off $("#city").single({ header: false }); // default $("#locality").multiselect({ header: true }); // off $("#roomtype").twoitems({ header: false }); // off $("#pricetype").twoitems({ header: false }); // off $("#price_value").multiselect({ header: false }); }); $(document).ready(function($){ $('#mega-menu-tut').dcMegaMenu({ rowItems: '3', speed: 'fast' }); }); $(document).ready(function() { $('a[id^="edit"]').fancybox({ 'width' : '48%', 'height' : '82%', 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe', onClosed : function() { parent.location.reload(true); } }); $('a[id^="icard"]').fancybox({ 'width' : '40%', 'height' : '40%', 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe', }); $('a[id^="upload"]').fancybox({ 'width' : '40%', 'height' : '40%', 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe', }); $('a[id^="delete"]').fancybox({ 'width' : '20%', 'height' : '20%', onStart : function() { return window.confirm('Do you want to delete'); }, onClosed : function() { parent.location.reload(true); } }); });
VIEWS ON THIS POST

92

Posted on:

Sunday 23rd December 2012
View Replies!

simple error - Reference error clearform

Hi I've thieved some code from an example site, and edited it to fit my needs.. but something is wrong.. this code works if I create a .html file and just open it locally, but after adding it to a website (joomla CMS).. then something is wrong This is the code: function CalculateSum(Atext, Btext, Ctext, Dtext, form) { var A = parseFloat(Atext); var B = parseFloat(Btext); var C = parseFloat(Ctext); var D = parseFloat(Dtext); form.Answer1.value = (((((8 / 50)*A)/D)*5)/C)/500*B; form.Answer2.value = B / D; } function ClearForm(form) { form.input_A.value = ""; form.input_B.value = ""; form.input_C.value = ""; form.input_D.value = ""; form.Answer1.value = ""; form.Answer2.value = ""; } // man taster det antal ml. man gerne vil give pr. uge. // man indtaster det antal ml. man vil opblande i //man indtaster strrelsen p akvariet // end of Javascript functions --> Mikroberegner Hvor mange liter er akvariet p\t: Hvor mange mililiter vil du gerne opblande i: Hvor mange mililiter vil du gerne give: Hvor mange gange om ugen vil du gerne dosere: Answer = Answer = The error seems to come from the last section, and specifically when I press the add values and clear form buttons.. errors are: ReferenceError: CalculateSum is not defined [http://www.akvarieplanter.dk/mikroberegner:267] ReferenceError: ClearForm is not defined [http://www.akvarieplanter.dk/mikroberegner:268] The webpage is here: http://www.akvariepl...k/mikroberegner I am, of course, hoping for some help fixing this.... Please feel free to visit the calculator and let me know if there's something I can try.. :-) Oh, and if I upload the same code in an html file, and access it via site/test.html, then it works... ! This post has been edited by Symbiot: 10 January 2012 - 11:03 AM
VIEWS ON THIS POST

97

Posted on:

Sunday 23rd December 2012
View Replies!

Form won't POST from innerhtml

, So I load a form through a XMLHttpRequest and set the content of a div to the returned data, which contains a form, problem is I can't submit this form when it is requested through Javascript, but I can submit it when it is standalone. I am thinking that this is probably a security setting in the browser to prevent XXS attacks But I am not sure, why doesn't it work It is nothing fancy just a regular old HTML POST form and a Javascript AJAXey request.
VIEWS ON THIS POST

110

Posted on:

Sunday 23rd December 2012
View Replies!

Contact form

I know its not the best idea to have a contact form in Javascript, but my PHP contact is not working where I have my clients site hosted (mezoka, they run php 5, but not phpmail().). Could someone possibly help me out, when I run my Javascript form, I dont get an email to my address when I test it. Contact