Frequently Asked Questions | JavaScriptSource

Frequently Asked Questions

JavaScriptSource Staff Nov 27, 2000

Here are the most common questions we get regarding The JavaScript Source, JavaScript programming, script debugging, script limitations, and more. Please feel free to browse the FAQs below for your question. If you are unable to find the answer you are looking for, please post your question to our JavaScript Forum where other JavaScript experts and our own webmaster can assist you.

Site Info

  • Are the JavaScripts here free? What is the catch?
  • Yes, we offer our site as a free "public service" resource. Simply stated, all the scripts on this site are free for personal or business use. The only requirement for use of archives is that you leave the credit information inside the script. We also don't think it's too much to ask if you would please link back to The JavaScript Source site to help spread the word about our site. The address for linking to The JavaScript Source is:

    http://www.JavaScriptSource.com

    Thanks!

  • Do you write all the JavaScripts in this site?
  • No, of course not. There are several thousand of them!

    What we do is collect many from across the Net and provide them in an organized and useful way. (We also write a portion of them.)

    If we have collected it from the Net, it will have the author credit info in the script.

    If there is not credit info, just the one for our site, then we wrote it or it is a 'public domain' script (it is commonplace and no one is any longer credited for it).

  • Can I get all your site's scripts in one ZIP file?
  • Unfortunately, we no longer offer a ZIP'd version of all the scripts on our site. We have done so in the past and found dozens of situations where users would upload our entire script archive to their own servers, and promote the site under a new name as their original work. For these piracy reasons, we no longer distribute a copy of our scripts in this manner.

    However, you are more than willing to browse and look around the site to find the scripts you want, then add them to your site that way. The Site Search feature also should help you find the exact script you are looking for when you enter a few keywords.

  • Are the scripts from this site virus scanned?
  • There is absolutely no way you can get a virus by visiting our site or using any of our scripts. Here's why:

    The text codes cannot transmit a virus to you. The .zip files are created by us and thoroughly scanned before being posted online. Regardless, we always recommend using a virus protection software when using a computer connected to the internet.

  • Can I advertise on The JavaScript Source site?
  • Yes! Advertising is the only way we can continue to provide this free resource.

    For more information about advertising on The JavaScript Source, go to:

    http://www.javascriptsource.com/mediakit/index.html

  • What's the 'javascript' error message I'm getting?
  • The error message is Netscape's way of telling you that there is a JavaScript error on the page you are viewing. If you type in:

    javascript:

    (note the colon!) it will open up the Communicator console (works in Firefox also) where you can see what the error message was. If you are not the site's webmaster, you can safely ignore the message and continue your surfing without any worries. Of course, I'm sure the site webmaster would appreciate it if you would let them know about their error!

    A lot of people seem to be typing javascript (without the colon) into the location bar and eventually ending up at The JavaScript Source site, which of course we don't object to! Trust me, your JavaScript is working fine, there is just an error on the page you were viewing. We are not doing anything to the Web page or trying to sell you something, or trying to communicate with you, really.

    Thanks for visiting the site.

General

  • What is JavaScript? Is it the same as Java?
  • JavaScript is NOT Java. JavaScript is a basic scripting language that allows Web authors to create dynamic pages that react to user interaction.

    JavaScript is based loosely on the Java programming language. JavaScript programs are contained within the HTML code of the Web page and are interpreted by the browser as it its read in contrast to Java programs that are downloaded separately from the HTML page. JavaScript is a "safe" programming language, one that cannot access any system controls or hardware on a user's computer.

    JavaScript provides greater flexibility to the Web designer through such luxuries as being able to create windows, display moving text, sound or other multimedia elements with relative ease. JavaScript often is used in place of common CGI operations, like verifying form input. It can also be used to control Java applets or plugins or open up new browser windows to aid in site navigation.

    JavaScript code can be inserted in <SCRIPT> tags within a page's HTML code, or embedded into a page to react to HTML "event handlers," such as a page loading, a button being clicked, or a window opening.

    JavaScript was first introduced in Netscape Navigator 2.0 and is supported in all subsequent versions of Netscape. Microsoft's JScript, their own version of JavaScript, inconsistently supports JavaScript (while causing errors the rest of the time) in Internet Explorer 3.0 and above. All modern browsers can interpret JavaScript (with a few irritating side-effects for older browsers).

    Overall, JavaScript is a fairly universal extension to HTML that can enhance the user experience through event handling and client-side execution, while extending a Web developer's control over the client's browser. How to do this is the subject of our site.

  • What JavaScript versions are covered on this site?
  • This site has examples through JavaScript version 1.5, the version deployed in Netscape Communicator 6.0 and Mozilla, plus some compatible items in Microsoft Internet Explorer 3.0x. The focus is on client-side JavaScript.

  • What browsers do the scripts work with?
  • The scripts *should* all work in current versions of all major browsers unless otherwise noted in the script's description.

  • What’s not covered here?
  • Other browser-based scripting languages such as Microsoft VBScript, Server-side JavaScript, and Netscape LiveWire Pro, database connectivity, known bugs, Netscape's JSRef source libraries for embedding the JavaScript interpreter in third-party code, etc.

    Netscape's JavaScript Reference (zip file) is available on our site at:

    http://www.javascriptsource.com/tutorials/CoreReferenceJS15.zip

    Netscape's JavaScript Guide (zip file) is also available on our site at:

    http://www.javascriptsource.com/tutorials/CoreGuideJS15.zip

Documentation

  • Where can I find online documentation?
  • Here's some of the best online JavaScript documentation:

    Core Reference: http://www.javascriptsource.com/reference/core_ref/contents.html

    Tutorials: http://www.javascriptsource.com/tutorials

    Microsoft JScript documentation: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsoriJScript.asp

  • What are the HEAD and BODY sections you mention?
  • An HTML page usually looks like this:

    <HTML>

    <HEAD>

    <TITLE>Page Title</TITLE>

    </HEAD>

    <BODY><div id=EchoTopic>

    .. page text here

    <BODY><div id=EchoTopic>

    </HTML>

    Each script's instructions are intended to assist you in copying the code to the correct section of your HTML page in order for the script to work properly. Try using the above code as a template.

How Do I...

  • How do I make an image slideshow?
  • Check out our slideshow scripts at:

    http://www.javascriptsource.com/miscellaneous

  • How do I clear the user's cache?
  • There are several things that can't be done with JavaScript for security reasons, including such things as changing user preferences or clearing the cache.

    However, I do have a slick workaround that prevents a page from being stored in the user's cache. (You don't have to clear the cache if the page isn't in the cache!) Anyways, on with it. The code to stick in the HEAD section of your page is this:

    <META HTTP-EQUIV="pragma" CONTENT="no-cache">

    <META HTTP-EQUIV="Expires" CONTENT="Thu, 01 Dec 1994 120000 GMT">

    Note: The second 'Expires' tag is not necessary for all browsers, but some browsers do use with the 'no-cache' tag, so it is best to just leave it in for good measure.

  • How do I hide the Web site URL while browsing?
  • Load your site in "hidden" frames, so the location address stays at your main page. To start, save your main home page as a new file, such as main.html

    Then, create a new HTML page with these contents, save it as blank.html:

    <html>

    <body><div id=EchoTopic>

    </div></body>

    </html>

    Then, put this frameset code in your index.html home page,

    <frameset rows="100%,*">

    <frame src="main.html">

    <frame src="blank.html">

    </frameset>

    This will load two frames (with the second one not even being shown) and keep the same URL in the location bar as they navigate your site.

  • How do I get user info, i.e. IP, e-mail, etc?
  • Look into getting a Java applet to do this deed for you.

    You can, however, get the IP address of the visitor if they have Java enabled - and are using Netscape - might work in Internet Explorer, not sure though.

    http://www.javascriptsource.com/user-details/ip.html

    For Java sites, try:

    http://www.javaboutique.com

  • How do I receive the form contents via email?
  • There's a form action line you need to change to where your "formmail" program is on your server (assuming you have one)

    <form action="YOUR-CGI-SCRIPT.CGI"...

    If you do not have CGI access, you can get a remotely hosted CGI Script to receive the from contents and email them to you. There are many free versions listed at:

    http://cgi.resourceindex.com/Remotely_Hosted/Form_Processing/

  • How do I print out a footer on my html pages without SSI?
  • In version 4.0+ browsers, JavaScript can actually read from an external (.js) file and include that code on the bottom of each page. The script is in our archives at:

    http://messages.javascriptsource.com/footer-text.html

    Note: Some servers do not support external .js files. Contact your system administrator to ensure you can run it on your site.

  • How do I get the Microsoft menu to my site?
  • We don't have that exact code because it's their copyright, but you might like:

    http://www.webreference.com/dhtml/hiermenus/

  • How do I prevent a "view source" on my site?
  • Unfortunately, the simple answer is "You can't." The browser must have access to clear HTML source code in order to produce a readable version for the user. There is no way to produce an HTML document that can be viewed in a browser window but whose source cannot be at least partly examined.

    Most browsers even have functions like "View Source" and "Save As HTML" to give others access to your code. HTML is not particularly complicated; Although there are work-arounds (such as opening a new window with menubars off) none actually make your code inaccessible. A visitor (snoonii@yahoo.com) also reports that by having your site include Micromedia's Flash plugin animation, the JavaScript code created by Flash won't be accessible to the visitors via "view source." Thanks the the tip!

    Furthermore, you might like http://www.javascriptsource.com/page-details/no-right-click.html for a solution that prevents the right click on your page most of the time....

    Because HTML is simple, hiding the complete source code would probably be difficult even if the source were not visible.

    Good HTML style, on the other hand, is a subtle thing and requires a high degree of consistency and editorial sense (not always displayed in this document ;-). It is unlikely that anyone will succeed in stealing your "style" using the "View Source" button, although they may pick up a few tricks.

    If you're afraid of having your material copied or stolen, and you don't believe copyright protection will adequately protect your interests, then don't publish your material on the World Wide Web or at least don't publish it in HTML. You'll have to find another distribution mechanism, or another media format, that provides the security you need.

  • How do I protect an image on my site?
  • You can take the "No Right Click" script at

    http://page-details.javascriptsource.com/no-right-click.html

    and change the two lines that read:

    for (var i=0; i<document.images.length; i++)

    document.images[i].onmousedown=right;

    So that they only set the protect function for the onmousedown effect of just the one image.

    So, count what number the image is on the page. Count the first image on the page as zero (yes, it starts as zero not one) then the next as one, the next as two, etc. Until you find the number of the one you want to protect.

    Then, change the two lines above to read:

    document.images[4].onmousedown = right;

    (where 4 is the number of the image you want to protect)

  • How do I rollover (change when touched) an image?
  • This effect is accomplished through JavaScript.

    First, get the Change Image JavaScript coding from:

    http://www.javascriptsource.com/miscellaneous/change-image.html

    The part that confuses most JavaScripters is the numbering in the coding. The numbers just tell the script which image to change "onMouseOver and onMouseOut."

    Note: When referencing images in JavaScript, counting starts from 0. The first image on the page is 0, the second image is 1, etc...  (i.e. a 3 would actually represent the 4th image on the page)

  • How do I scroll a page/frame of my site?
  • If you would like to scroll a page and your site it is not in frames, you can use our Vertical Scroller, found at:

    http://scrolls.javascriptsource.com/vertical.html

    If your site is in frames, however, there is a small modification to the Vertical Scroller script to make it scroll a frame. Assuming you gave each frame a name in the FRAMESET:

    <frameset rows="50%,50%">

    <frame src="page1.html" name="page1">

    <frame src="page2.html" name="page2">

    </frameset>

    You can scroll the contents of another frame (i.e. page1) by putting the Vertical Scroller code in page2, which could be enacted by a button, or a link, or on page load or.... You get the idea.

    <SCRIPT LANGUAGE="JavaScript">

    <!-- Begin

    function scrollit() {

    for (I=1; I<=750; I++){

    parent.page1.scroll(1,I)

    }

    }

    // End -->

    </SCRIPT>

    You can call the scroll function in any of these methods:

    <a href="javascript:scrollit()">Scroll Other Frame</a>

    or

    <form>

    <input type=button value="Scroll Other Frame" onClick="scrollit()">

    </form>

    or

    <body onLoad="scrollit()">

  • How do I submit a form in JavaScript?
  • The most reliable way is to use straight HTML via a Submit style button, by setting the ACTION of the <FORM> to a mailto: URL and the ENCTYPE attribute to "text/plain". For security reasons, the form.submit() method does not submit a form whose ACTION is a mailto: URL.

    So, you need a CGI-Script form processor to accept the form submission and mail you the results. If you are allowed to run CGI-scripts on your site (contact your system administrator to be sure) then you can gea form processing script from:

    http://cgi-resources.com/Programs_and_Scripts/Perl/Form_Processing/ (one long address)

    If, however, you are hosted with Geocities, Angelfire, or another free hosting service or are just unable to run CGI-scripts on your site, then you need a remotely hosted form processing CGI-script. Many are listed at:

    http://cgi-resources.com/Programs_and_Scripts/Remotely_Hosted/Form_Processing/ (one long address)

    As soon as you set up your own form processing script, or have a remotely hosted one ready, just substitute the form processing script's address into the form action, like this:

    <form action="http://www.somesite.com/cgi-bin/form-processor.pl">

  • How do I change my e-mail address for the newsletter?
  • You can accomplish this by unsubscribing to the old version. You can do this by clicking the link at the bottom of the newsletter and then sign up for the newsletter you want from our home page, or

Script Help

  • How do I make help popups work in frames?
  • First, copy the code from the yellow source code box at:

    http://messages.javascriptsource.com/help-popups.html

    Now, you need to be sure you gave each frame a name in your FRAMESET code. Open your FRAMESET code and make sure that give each frame a name, like this:

    <frameset rows="50%,50%">

    <frame src="help-popups.html" name="frame1">

    <frame src="other-page.html" name="frame2">

    </frameset>

    Then, about 100 lines or so through the script, in the startHelp() function, find the line that reads:

    var cmdstr="top." + this.name + ".showHelp('" + msgindex + "')";

    Then change it to read:

    var cmdstr="top.frame1." + this.name + ".showHelp('" + msgindex + "')";

    To make the script work in frames, we only had to change "top." to "top.framename." Just substitute into framename the name of the frame that has the help-popup code.

  • How do I display the clock for just one timezone?
  • Check out

    http://www.javascriptsource.com/clocks/world-clock.html

  • How do I change passwords for cookie password script?
  • The passwords are actually not "set" in the script. Instead, it relies on a basic method of password verification. If:

    password1 + password2 = password3

    then they can enter the site. For example:

    java, script, javascript

    and

    test, ing, testing

    work, but this set does not:

    let, me, in

    ("let" + "me" -- which equals "letme" -- does not equal "in").

    So, to actually use this script on your site, we recommend you give each user a differnet password set that fulfills the pattern.

  • The script works, but why do I see a broken image icon?

Troubleshooting

  • What can't JavaScript do?
  • JavaScript was designed to pose a "slim to none" security risk. For that reason, JavaScript can not do the following:

    Read to or write from external files (except .js files)

    - Interact with ASP pages or databases

    - Control browser e-mail, bookmark windows, or menus

    - Access or modify browser settings

    - Capture visitor e-mail address or IP addresses

    - Quietly send me an e-mail when a visitor loads my page

    - Launch client processes (Unix sendmail, Win apps, etc)

    - Change a document's background .gif after the page has loaded

    - Change the current browser window options

    - Change that "JavaScript Alert:" line in alert dialogs

  • What's a "run time" error?
  • There are three distinct areas where errors can occur in any computer program:

    Load-time errors

    Run-time errors

    Logic errors

    Load-time errors: Errors detected when loading the Web page (leaving off a parenthesis, improper syntax, etc.)

    Run-time errors: Loaded fine, but a misuse of the language's commands caused an error while running.

    Logic errors: Reaches the wrong answer after being run - a "bug". Test and test and test again to find these.

  • What are the most common scripting mistakes?
  • Here are the most common mistakes programmers run into with JavaScript:

    - Missing or mismatched quotation marks ' and "

    - Missing or mismatched '{' or '}'

    - Confusing '=' (assign) and '==' compare)

    - Improperly nesting IF-THEN-ELSE statements

    - Calling objects through window not document property

    - Endless loops that lock up the browser

Miscellaneous

  • Is there a "new scripts" mailing list for this site?
  • Yes, actually there is! Just sign up for JavaScript Source News and we will keep you up to date with what is going on at The JavaScript Source - When we add new scripts or new features, major site annoucements, and other important information.

    Or, sign up for our JavaScript Updates newsletter, which we will send out every time we add another script to the site, add a new feature, and so forth.

    For more information, or to sign up, visit:

    http://www.javascriptsource.com

  • Where else can I look for more JavaScript info and examples?
  • We recommend you also take a look at the scripts over at EarthWeb.com:

    http://webdeveloper.earthweb.com/webjs/

    There are quite a few excellent JavaScript resources that may useful to you.

    (We recommend Script Search - http://www.scriptsearch.com/JavaScript/)

  • Can I remove the "credit" line in the JavaScripts?
  • We are not going to say that you can not remove them, but we would really appreciate if you left them in. I do not think it is too much to ask that you leave them intact, especially since we do not require any sort of payment for the scripts in The JavaScript Source.

  • How do you add an icon next to your site in "favorites"?
  • That is actually MSIE 5.0's favicon.ico feature.

  • Where can I get the script for the "Email-A-Script" feature?
  • There are many file management scripts listed at

    http://cgi.resourceindex.com/Programs_and_Scripts/Perl/File_Management/

    that can do this for you. We decided to use a modified version of FreeScripts.com's MailFile CGI-script, which can be found at

    http://www.FreeScripts.com/html/mail_main.shtml

    We made the file to send a hidden field in the form, and customized the email that was sent out a bit.

    (Please note that you will need to be able to have CGI-scripts on your site to use that program. Check with your site administrator to ensure you can do this.)

About Us

  • Who runs this site?
  • The JavaScript Source is a part of the Developer.com network, owned by QuinStreet. This site was founded in 1996.

  • Can you help me with [anything here] ?
  • Due to the large number of "help" requests I receive daily, combined with the requirements of running the JavaScript Source, we are simply unable to personally help you with your scripting problem.

    As a solution, we have provided The JavaScript Forum where you may post a "help" message, and have other visitors to our site help you with it if you ask nicely!

    As well, you can post JavaScript requests, Web site feedback, and general JavaScript messages.

    The JavaScript Forum:

    http://www.webdeveloper.com/forum/forumdisplay.php?f=3

  • Can you check my site for JavaScript errors?
  • Sorry, but I am unable to do this - the sheer number of requests coupled with the demands of running the JavaScript Source do not allow me to do this for you. You can discuss the problem over at the JavaScript Forum:

    http://www.webdeveloper.com/forum/forumdisplay.php?f=3

Leave a Response

(8 comments)

I am trying to post a picture from my files onto a blog. However, I get the message - javascript void (0). What do I need to do to be able to correct this so that I can post these pictures to my blogs?

Alice Jun 13, 2013

How can i unloud javascript in my iPad

Sandra Serna Oct 1, 2012

i can create that date column in gridview as Unique, so that whenever any duplicatevalue is inserted you can catch the exception from the database and can told the user that this date is already enterd or you have to check all the rows of the gridview to check that the date is unique or not... function InsertUniqueDate(GrdvewHoldyDate, txtdate) { var flag = 0; var GrdvewHoldyDate = document.getElementById(''); var txtdate = document.getElementById(txtdate); var gridLength = GrdvewHoldyDate.rows.length; for (var i = 1; i

ros Sep 21, 2012

Hw can I download javascript on my bb phone

kosoko eniola Sep 13, 2012

great site.. not what i was looking for and tripped into a wonderful information pit!!

lane Sep 10, 2012