deconstructing a javascript - Post ID...

User 26420 Photo


Registered User
5 posts

Maybe someone can help me in desconstructing the following script. How do I read the scipt's code concerning imgs and page? what is a function hook? How do I read -> window.open(p,"",windowprops);

var n = 0;

timedelay = 3; // 3 secs between pics
timedelay *= 1000;

windowprops = "top=250,left=15,width=200,height=200"; // customize the popup window here

var imgs = new Array();
imgs[0] = "http://www.your-site.com/images/image1.gif";
imgs[1] = "http://www.your-site.com/images/image2.gif";
imgs[2] = "http://www.your-site.com/images/image3.gif";
imgs[3] = "http://www.your-site.com/images/image4.gif";

var page = new Array();
page[0] = "http://www.your-site.com/page1.html";
page[1] = "http://www.your-site.com/page2.html";
page[2] = "http://www.your-site.com/page3.html";
page[3] = "http://www.your-site.com/page4.html";

function hook() {
var p = (n == 0) ? page[page.length-1] : page[n-1];

window.open(p,"",windowprops);
User 132952 Photo


Ambassador
3,120 posts

I have a feeling you know what this code is supposed to do. Might help letting us know as well. :) What do you want to do with it? Without knowing what it means, I'm sure it's safe to assume you can change the your-site links to your own, if that code does what it is that you want. Kinda workin' blind here.
User 51909 Photo


Registered User
3,694 posts

I am pretty sure that this script displays random images.

Mark
Mark Loves CoffeeCup
User 26420 Photo


Registered User
5 posts

"Maybe someone can help me in desconstructing the following script. How do I read the scipt's code concerning imgs and page? what is a function hook? How do I read -> window.open(p,"",windowprops);"

Yes I think I know what the code is supposed to do:) At least in general terms.

The business site I manage was developed by a professional web designer.It is an asp site and filled with his coding. I'm now having to maintain and make some modifications myself. Being a person with a little knowledge can be a dangerous situation. I can't take a chance of changing the live site until I have first tested my changes locally.

I recognize that I lack some basic knowledge.
for example http://www.your-site.com/images/image1.gif";
how do I change the path so the images are loaded from a folder on my pc and not from a web site. Do I change http to img src, href?

Off forum help said change to your local path. If only they had told me how to make the changes along with an example.

I do not underdstand what is being accomplished by:
http://www.your-site.com/page1.html
why load a page?

I can gather that JS is building two arrays. images and pages;
and Windowsprop is setting the popup window properties

I googled for "function hook" and came up with
"The hook function concept is introduced to allow a fine control all the messages that a window and all of its children receive, and to decide to let the callback function attached to the receiving window to handle the message or not."
Plus a number of definitions written in computer speak.

I am basicly a cut, paste and fake it developer:) I get befuddled when the code looks the same as something in a book but "different" <big gryn>. I've learned to speak the speak but don't know what it means.

What I want to do is display a series of images. After I learn how to dothat I want to learn how to stream images across a window in the page.

I understand how to change the URLs to my own sites but don't know how to load from my folder "LearningJS" on my C drive.
User 133269 Photo


Registered User
2,900 posts

Hi Dave - dont know much about js sorry but can tell you how to make a path to a local file....

src="file://C:\Documents and Settings\....."

:)
Have fun
~ Fe Pixie ~
User 51909 Photo


Registered User
3,694 posts

Fe Pixie wrote:
Hi Dave - dont know much about js sorry but can tell you how to make a path to a local file....

src="file://C:\Documents and Settings\....."

:)

Pixie Lady, you beat me to that one. Even I knew that one.

M
Mark Loves CoffeeCup
User 51909 Photo


Registered User
3,694 posts

Dave - The US Geeks are either still in bed (lazy bunch) or are busy at work. I am pretty sure that when one of them either gets up or gets home from work, they will answer this one for you.

Mark
Mark Loves CoffeeCup

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.