Google Answers Logo
View Question
Q: Properties of a URL ( Answered 5 out of 5 stars,   1 Comment )
Subject: Properties of a URL
Category: Computers > Programming
Asked by: omoolorun-ga
List Price: $20.00
Posted: 15 Oct 2005 19:03 PDT
Expires: 14 Nov 2005 18:03 PST
Question ID: 580772
I wrote a slide show javascript and also downloaded similar scripts
from the web. Created HTML files using AceHTML PRo software for all
these slide show files. These files are on my C drive. I created a
file for all my pictures on my D drive with extension jpg.
On testing each slide show HTML code file in IE, Maxthon and Opera,
the first picture shows and not the rest of the remaining pictures.
Whenever I click next, for more pictures, I get a blank page with a
little red x where the
picture was to have been. Right clicking the red x and going to
Properties revealled this statement at the URL "file:///d:%02.jpg"
This is my code: "var picture = new Array("d:\1.jpg", "d:\2.jpg", "d:\3.jpg")
Can you explain File:///d:%02.jpg?

Request for Question Clarification by leapinglizard-ga on 15 Oct 2005 19:24 PDT
I might be able to help you with this, but I need to see more. Can you
show me the HTML source for the page and all related JavaScript code?


Clarification of Question by omoolorun-ga on 16 Oct 2005 20:51 PDT
Thanks a lot for your quick reply. Below, please find my code.
Hope this helps.

<?xml version="1.0" encoding="windows-1252"?>
<html xmlns="">
<!-- Created on: 9/10/2005 -->
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Slide Show Lesson #12</title>
<script Language="JavaScript">
var picture = new Array("d:\1.jpg", "d:\2.jpg", "d:\3.jpg", 
			"d:\4.jpg", "d:\5.jpg", "d:\6.jpg", 
			"d:\7.jpg", "d:\8.jpg")
var picNumber=1
var numberofPics = picture.length

function nextPicture(){
  if(picNumber < numberofPics){
<body bgcolor="white">
<img src="d:\1.jpg" name="myPicture" width=400, height=400>
<a href="JavaScript:nextPicture()">Next Picture</a>
Subject: Re: Properties of a URL
Answered By: leapinglizard-ga on 16 Oct 2005 23:02 PDT
Rated:5 out of 5 stars
Dear omoolorun,

The reason your page correctly displays the first picture is that its
location is specified by the HTML code as src="d:\1.jpg", which
translates directly into the string "d:\1.jpg".

But when you click on the "Next Picture" link and the JavaScript gets
called, the next element of the array is "d:\2.jpg", which gets
translated by the JavaScript interpreter into the invalid location
"d:%02.jpg". This is because the backslash character, "\", has a
special meaning in JavaScript that causes it to render special
characters. If you intend a JavaScript string to include the backslash
character itself, you must write it twice in a row: "\\". Thus, when
you are using a JavaScript string to specify the file location
d:\2.jpg, you should write it as "d:\\2.jpg".

You will find that the HTML source code below achieves the intended
effect. If you wish to preserve your own prefatory tags, you can just
cut the script out of your current file and paste in my own as a

If you have any trouble carrying out this substitution, please advise
me through a Clarification Request so that I can make sure everything
is working at your end before you rate my answer.



<script language="JavaScript">
    var picture = new Array("d:\\1.jpg", "d:\\2.jpg", "d:\\3.jpg", 
                            "d:\\4.jpg", "d:\\5.jpg", "d:\\6.jpg", 
                            "d:\\7.jpg", "d:\\8.jpg");
    var picNumber = 1;
    var numberofPics = picture.length;

    function nextPicture() {
        if (picNumber < numberofPics){
        else {
            picNumber = 1;
        document.myPicture.src = picture[picNumber-1];

        <img src="d:\1.jpg" name="myPicture" width=400, height=400>
            <a href="JavaScript:nextPicture()">Next Picture</a>
omoolorun-ga rated this answer:5 out of 5 stars
Great job and thanks!

Subject: Re: Properties of a URL
From: wildwestwind-ga on 15 Oct 2005 19:44 PDT
In JavaScript the character \ embedded in a string is a special
"escape" character which modifies the following character rather than
representing \ itself.  In order to create \ as output you need to
double it, as in "\\".

So you might want to try

  var picture = new Array("d:\\1.jpg", "d:\\2.jpg", "d:\\3.jpg")


  var picture = new Array("d:/1.jpg", "d:/2.jpg", "d:/3.jpg")

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy