Click here to Skip to main content
15,892,161 members
Everything / Programming Languages / Javascript

Javascript

Javascript

Great Reads

by Colin Eberhardt
This article describes the development of a cross-platform HTML5 application for Windows Phone and iPhone.
by Steve Krile
Fully AJAX-enabled user control used to select names from a database in a drop-down format.
by Marcelo Ricardo de Oliveira
A shoot'n'up HTML5 game made with Phaser game framework
by Serge Desmedt
A try it yourself guide to the basic math behind perceptrons

Latest Articles

by Xavier Junqué i de Fortuny
Converts MathML coded string to/from plain text string
by Member 4206974
FormGen, a JavaScript Form Generator
by Jeremy Falcon
Just a simple routine and helper routine to generate unique IDs suitable for disconnected systems.
by Matthew Dennis
Create a ChatGPT-like AI module for CodeProject.AI Server that handles a long-running process.

All Articles

Sort by Updated

Javascript 

4 Mar 2018 by !DOCTYPE html
I've been trying to have a tag occur when I hover over each of the markers on this map, describing what Is here and why to visit these places, but I don't know how. Does anybody know how to make this happen? What I have tried: This is what I've been working with. Since I don't know hot to make...
5 Jul 2018 by !DOCTYPE html
Hi! So I came across a problem in the JS code below. My if/else statement will only show the oeramiter for "If", even when I put in 123456. var age = ""; window.prompt("How old are you?", 50); if (age
5 Jul 2018 by !DOCTYPE html
Hi! So i have been trying to create the pattern below using nested for or while loops, however my code does not seem to put out what I need. In fact, It displays nothing! Pattern: * ** *** **** ***** ****** ******* ****** ***** **** *** ** * Below is the code I have been trying out. What I...
1 Feb 2010 by #realJSOP
Don't know anything about that.
29 Apr 2010 by #realJSOP
Go to the article where you want to ask the question. Each article has it's own message group. I'm deleting this question.
12 May 2010 by #realJSOP
Well, if your div's ID is "position" (and your tags are properly closed in the HTML), you should be able to use content.InnerHtml to retrieve everything inside the div.At that point (according to your piss-poor description), you can simply call string.Split(',') on the "inner html" and...
19 May 2010 by #realJSOP
Put a try/catch block around it and ru it under the debugger to see exactly what the error is. At that point, you should be able to figure it out.
10 Jun 2010 by #realJSOP
I googled it, and found this:function mytest1() { var Excel, Book; // Declare the variables Excel = new ActiveXObject("Excel.Application"); // Create the Excel application object. Excel.Visible = false; // Make Excel invisible. Book = Excel.Workbooks.Add() //...
11 Jun 2010 by #realJSOP
I'm deleting this version because it's a repost.
17 Jun 2010 by #realJSOP
You have more control over what's happening with method #2. That's the one I would choose. However, don't forget to add the requisite try/catch/finally block to handle any exceptions that might occur.
26 Jun 2010 by #realJSOP
I know, it\'s tempting to be a lazy git instead of just looking around or even - GAK! - search the site, so here\'s the FAQ for submitting articles. Make sure your read THE WHOLE THING.Code Project Article FAQ[
27 Aug 2010 by #realJSOP
A little google goes a long way:Close
27 Sep 2010 by #realJSOP
So read both files into separate strings, remove all of the spaces, tabs, and any other unprintable ascii character, and THEN compare the strings.
23 Nov 2010 by #realJSOP
Instead of doing that, set a radio item in the group as selected and the need to validate whether or not a radio button is checked is eliminated. If you have to, add a radio button that reads "Not selected", or somethig appropriate, and select it by default.
24 Nov 2010 by #realJSOP
I think when you get a javascript error, it also counts the lines in the hosting html file. Of course I could be wrong...
6 Dec 2010 by #realJSOP
You can't. You either need the service reference, or you need to use svcutil to generate the appropriate files for you. It sounds like you're trying to use a web service without permission from its owner.
6 Dec 2010 by #realJSOP
If you're using .Net, you can probably load the javascript into a BrowserWindow, and then use the DOM to extract the method names (let the DOM do the parsing for you). How you would specifically go about doing this, I leave to you as a programming exercise.
12 Dec 2010 by #realJSOP
My tip: Google is your friend.If you're a "beginner in asp.net", one really has to question the logic of assigning you the task of developing an enterprise-level web application. If I was in charge, I certainly wouldn't want a "beginner" to be involved at the level you're involved.
7 Jan 2011 by #realJSOP
Does this article help?http://ajaxpatterns.org/archive/Timeout.php[^]
28 Jan 2011 by #realJSOP
Oh yeah - like we're going to help you copy someone else's intellectual property...
18 Feb 2011 by #realJSOP
When I googled this, I saw conflicting reports of it working fine in IE but not in Firefox, and then working fine in Firefox, but not IE. I think you're just going to have to break down and google it yourself because you know more about what your page is doing than we ever could. You also...
8 Mar 2011 by #realJSOP
The problem is that you're trying to use them as if there's a valid numeric value in them. Before trying to use the values in those fields, check to see if they're NaN, and only then, do the desired math operations. In fact, I'd do this:var TxtSTUPort =...
12 Mar 2011 by #realJSOP
Try using HttpWebRequest instead. You have a lot more control over how it works than you do with WebRequest.
16 Mar 2011 by #realJSOP
OnFingerHover? :)I think I'd go with option 3, except you made it a point to say "some" devices, as if to say *some* device DON'T have suppport (or excellent support) for it.BTW, Liquid Nitrogen is in short supply because of the Tsunami in Japan.
6 Apr 2011 by #realJSOP
You can't directly call a code-behind method from javascript because that would be crossing the client side/server side boundary. I would think a workaround would be to set a hidden form variable to inidcate what method you want to call (in the event that there are more than one), and then call...
14 Apr 2011 by #realJSOP
I bet it's having a problem with document.getElementById (because javascript is client side, and the aspx page is server side?). Try putting the script into the section of the masterpage.
21 Apr 2011 by #realJSOP
Situation: You're on a web page with a small image displayed, and when you click on the image, the current browser window contents are "grayed out", and a window animates itself onto the screen to show the image in its actual size. The window has a Close button on it. I assume it's done in...
23 Apr 2011 by #realJSOP
Using FireFox 4.0:I was playing around with Lightbox2 last night, and I simply can't get it to load the control images (like loading.gif or closelabel.gif), even if they're in the same folder as the javascript. The applicable part of my site hierarchy looks like this:root Lightbox...
23 Apr 2011 by #realJSOP
Well, after fighting with lightbox2 some more, I decided to try shadowbox, and it worked as advertised without any changes, so I switched to that. Once complaint about shadowbox - it appears as if some sort of obfuscation has been applied because all of the variables and method names are...
29 Apr 2011 by #realJSOP
One program isn't going to bolster your resume. What got me my first programming job was that I not only attended school full time (I also have a certificate, and not a degree), but that I also held down a full-time job. Yeah, your first programming gig is gonna suck as far as compensation goes,...
3 May 2011 by #realJSOP
There's no such thing as a minimum protection level. Javascript can be turned off all by itself, the creating a "custom" protection level.The best you can do is detect whether or not Javascript is enabled, and put up the appropriate web page or other indication informing the user that...
5 May 2011 by #realJSOP
This is what I use on my web page:function GetSiteRoot(){ var rootPath = window.location.protocol + "//" + window.location.host + "/"; if (window.location.hostname == "localhost") { var path = window.location.pathname; if (path.indexOf("/") == 0) ...
17 May 2011 by #realJSOP
You can use WMI.I found this with a google search:http://www.htmlforums.com/client-side-scripting/t-using-wmi-with-javascript-123787.html[^]that returned over 920,000 results using this search phrasejavascript wmi[^]
22 May 2011 by #realJSOP
Here's a CodeProject article.File Search using Javascript[^]
14 Jun 2011 by #realJSOP
In your asp.net page (assuming you're using asp.net, because you didn't say whether you were or not), in the Page_Load event handler, do something like this:if (IsPostback){ if (credentials are valid) { Response.Redirect("authenticated_home_page.aspx"); }}
23 Jun 2011 by #realJSOP
If you want to pay someone to do work for you, there are sites on the internet that allow you to hire programmers. This is not such a site.Now, if you want to stop pussyfooting around and use real software on real hardware, try MediaPortal. It's free, runs on Windows, and it comes with...
30 Jun 2011 by #realJSOP
I use transmenu, but it's no longer being maintained. It's a javascript menu system. You can see an example of it here:My web site[^]You can get the last updated source here:http://youngpup.net/projects/transmenus/[^]It's also used in Joomla and DotNetPuke.
7 Jul 2011 by #realJSOP
Have you tried typing the entire name - cTimeLine.prototype.initUnits?
8 Jul 2011 by #realJSOP
This should explain it[^]
11 Jul 2011 by #realJSOP
No. We can't give you the templates because we don't have them. If they put their templates info files, you may be able to get to them by viewing the source of the ebay web page, finding the file names in the section, and then browsing directly to those files. No guarantees that's gonna...
20 Jul 2011 by #realJSOP
A google search would have done you a world of good.I found this[^] when I googled "ssis javascript".
26 Jul 2011 by #realJSOP
One of these methods:0) You need another javascript function that can fetch a row from the returned datatable, and then build/return a string that represents the html table row. You would need to make your datatable global.1) Write another method that accepts a datarow, and then...
27 Jul 2011 by #realJSOP
You need to learn how to spell complete words.
26 Jul 2011 by #realJSOP
Try this:document.referrer
28 Jul 2011 by #realJSOP
You're trying to use javascript events to run asp.net code-behind. You can't do that. Try writing some javascript code to do it.
7 Aug 2011 by #realJSOP
Is this an asp.net web site? Is it using ajax?EDIT ================You didn't answer my question, but okay.See if you have any .js files in your site folder, and look for anything that looks like initialization of a dropdown list. Failing that, start at "the search" that gets...
8 Aug 2011 by #realJSOP
One way:Add a hidden asp:Button to your aspx page (don't forget to add a click handler in your code behind), and from your javascript, just call the button's click method:var button = document.getElementByID("buttonID"); button.click(); Your click handler code can then call the...
9 Aug 2011 by #realJSOP
obj = obj || window.event;How can that possibly do anything useful?
9 Aug 2011 by #realJSOP
Depending on the browser, you already get that kind of functionality (Firefox already does it). Also, there are probably plugins for the browser that don't support it natively. Why would you want to duplicate that functionality in your code?A little googling goes a long way:Go here [^]
9 Aug 2011 by #realJSOP
You couldn't find this answer with google? Look into toUpperCase().var mystring = "abc";mystring = mystring.toUpperCase();
10 Aug 2011 by #realJSOP
One way is to do this:string a = "a";if (a == a.toUpperCase()){ // it's uppercase}Another way is with regular expressions:var check = /[:upper:]/;alert(check.test("R")); // returns truealert(check.test("r")); // returns false
10 Aug 2011 by #realJSOP
For god's sake, learn how to use google. EVERY one of your recent questions can easily be answered with even the most rudimentary of google searches.
12 Aug 2011 by #realJSOP
Use Fiddler [^] to figure out what the site is doing. That's what I do in a case like this.
12 Aug 2011 by #realJSOP
For Style tags, the HTML standard says they go there. For script tags, it depends on the script and its function. If you're loading a .js file, it goes in the head section. If you want the code to execute as part of the rendered page and it doesn't live in a method, and if we're talking about...
23 Aug 2011 by #realJSOP
Try Monster [^]. There are hundreds, nay, thousands of qualifed developers there looking for gainful employment. You would probably need to log on as an employer.
24 Aug 2011 by #realJSOP
Epic fail.This essentially qualifies as spam.
25 Aug 2011 by #realJSOP
This might help, but no guarantees:http://nishantrana.wordpress.com/2008/08/13/consuming-an-aspnet-web-service-using-soap-protocol-from-javascript/[^]
26 Aug 2011 by #realJSOP
In IE8 Standards Mode (as opposed to Compatibility Mode) the getElementById method is case sensitive. Is your ID name the right case? Should it be "ID", or maybe "Id"?
7 Sep 2011 by #realJSOP
Define "irrelevant data". With three or more points, it's impossible to have "irrelvant data". You can still calculate the area of the resulting shape by either considering the points in the order specified, or by "normalizing" the points so that the resulting shape is a closed-plane polygon.
8 Nov 2011 by #realJSOP
The onclick function you're trying to executre is a javascript function. If you were to use Wireshark to analyze what the page does when the user clicks abutton, you will be able to figure out the correct querystring to pass to make the right things happen. BTW, wireshark is a free tool, and...
12 Dec 2011 by #realJSOP
Have you considered asking FarceBook Developer Relations how to do it?
16 Dec 2011 by #realJSOP
if you can create GUIDs in javascript, just do that, and remove the hypens and curly braces if necessary. I found this with google:function createUUID() { // http://www.ietf.org/rfc/rfc4122.txt var s = []; var hexDigits = "0123456789abcdef"; for (var i = 0; i
18 Dec 2011 by #realJSOP
Just change the "/" to "%2f".mystring = mystring.replace("/", "%2f");
23 Dec 2011 by #realJSOP
Did you mean to do this:
7 Mar 2012 by #realJSOP
javascript:window.history.forward(1);Of course, if javascript is turned off in the client browser, the code above won't work. So, you'd probably have to check the referrer and redirect if necessary to the referring web page.
15 Jun 2012 by #realJSOP
One way to get around the "invalid character" error
29 Sep 2016 by #realJSOP
I'm gonna take a stab at this, despite your inability to communicate clearly in English.You need to hand the click event for the checkboxes in the list, and determine if the checkbox is checked or unchecked, and take the appropriate action.Now I remember why I stopped answering questions...
8 Nov 2016 by #realJSOP
Delete the semi-colon after the curly brace
23 Jan 2017 by #realJSOP
You don't need to select controls. You simply need to know the proper url/querystring format/contents, and submit that with the WebClient object.
11 Feb 2018 by #realJSOP
Yes, you can actually host a web page in your own application. I did it in this Codeproject article: CodeProject Article Scraper, Revisited[^] Scroll down to the section labeled "Visual Presentation".
27 Feb 2018 by #realJSOP
I wouldn't worry about maintaining an archive of older files unless that's a specific requirement. If it is, you can establish a max number of old files to maintain to keep disk usage on the file system server to a dull roar. Files can quickly overwhelm available disk space on a busy site. You...
16 Mar 2018 by #realJSOP
First, why are you worried about the index of the item you're editing? Seems weird given the nature of EditFor. Don't do it on the client side. Do it this way: @foreach(var item in Model) { @* if you really need the index, you can do this in a foreach loop *@ int index =...
28 Oct 2018 by #realJSOP
Pad the minutes and seconds values with a leading 0 if they're less than 10. 09 mins : 09 secs It also seems to me that if you simply displayed the time remaining without any words, it would still be completely readable (and you could include hours, even if you never need the value: Time...
4 Apr 2019 by #realJSOP
(The way I'd do it) Instead of having two buttons, use a checkbox to indicate whether the user does or does not have the role, and have a single submit button.
17 Apr 2019 by #realJSOP
DO NOT USE ACTIVEX. (Commonly referred to as "Active-Xcrement") Only Microsoft browsers support it, and anyone with have a brain avoids using it because it's insecure. There are too many examples of writing ADO code for an Asp.Net web site to have to use ActiveX.
13 Jun 2019 by #realJSOP
"prevent multiple tabs in browser of a given web site" - Google Search[^]
19 Jun 2019 by #realJSOP
If it were me, I'd establish files with static names, and copy the newest files (that the python script generates) to files with the static names. At that point, you simply load the same file names every time, which completelty eliminates the need to scan the folder.
17 Oct 2019 by #realJSOP
comparedTo is a function contained in the BigNumber object. You have to look at the source code for that object to find it.
8 Nov 2019 by #realJSOP
0) The delay does not go on the page where the user clicked the link - it goes on the page that has the download button. 1) To make a link open in a new tab, add target="_top" to the href. 2) You should respond to an event in order for the html to be rendered. 3) For the record, these...
21 Dec 2019 by #realJSOP
This article might help: A Handy GPS Class [^]
29 May 2020 by #realJSOP
Once the line color is set in a line chart, you can't change it based on the value of a data point. No chart library that I'm aware of is going to let you do it. You have two options: 0) create another line (a different color from your data...
7 Feb 2022 by #realJSOP
There's at least one article here n CP that describes some methods for doing this: Different Ways to Pass Data to Partial View[^]
2 Feb 2023 by #realJSOP
I'm using MaterialTable, and I want to add some functionality. This new functionality does not necessarily override default functionality. How can I do that? What I have tried: This is one of the few things I can't find anything about on Google.
24 Sep 2013 by $*Developer - Vaibhav*$
Hi All, Convert XML string to Array but array is array item within item 1 SDM SDM78@gmail.com #4169e1 10010000 XYZ...
25 Sep 2013 by $*Developer - Vaibhav*$
Using parseJSONvar obj = jQuery.parseJSON( '{ "name": "John" }' );alert( obj.name === "John" );
6 Dec 2016 by $*Developer - Vaibhav*$
[How to Call javascript function on button click event]
24 Oct 2011 by $aikumar$ Cilamkoti
Hi All,I just want to Clear the History of the Browser using the Javascript...any suggestion please welcome,in other words just want to disable the Back button of the browser..
26 May 2014 by $ultaNn
I tried below codes to get IP from client machine but fail to get the appropriate IP CODE1Using this code i am getting IP 100.43.0.212of my server where i have uploaded my website private void IPAddress() { IPHostEntry host; string localIP =...
21 Dec 2021 by $ultaNn
Please can anyone provide a method to calculate the difference between 2 hijri dates start date 01/10/1429 End Datem 04/23/1436 Output 7Y 3M 14D What I have tried: function CalculateDate() { var startDate =...
17 Mar 2022 by $ultaNn
I have to calculate number of days between two dates but every month is of 30 30 x 12 = 360 , What I have tried: function diff_year_month_day(dt1, dt2) { var time =(dt2.getTime() - dt1.getTime()) / 1000; var year =...
22 Jan 2023 by $ultaNn
i am trying below code to print only from javascript without html popup page var a = window.open('', 'PRINT', 'height=900,width=600'); a.document.write(''); a.document.write( '' + ...
23 May 2002 by 'Anil' Radhakrishna
search multiple sites at once
4 Jul 2002 by 'Anil' Radhakrishna
Search multiple sites at once and view results on a single page
2 Jul 2002 by 'Anil' Radhakrishna
A Frill-free way to submit Forms and Parent-Child window communication
4 Jul 2002 by 'Anil' Radhakrishna
Fun with Frames
21 Mar 2003 by 'Anil' Radhakrishna
Mimics PowerPoint functionality & can be used for short text messages
25 Jul 2011 by 'Anil' Radhakrishna
A mash-up of sorts built using Microsoft's jQuery Template plugin along with G Birke's jQuery Pagination plugin & a photo-stream from Flickr acting as a data source