/    Sign up×
Community /Pin to ProfileBookmark

Code needed for window object and arrays!!

I need code which incorporates 3 windows – The first window, window “a” will be the opening window, this contains the start page. Javascript will not be used to open this first window – one would simple use ‘file- open file’ to open this page. Call it firstwindow.html –
-Window “b” will be the pop up window that will be dynamically created and into which one would write text into.
-Window “c” will be the window in which you will load an external site; you will not be creating this page but rather loading this link into a new window.

Window “a” details:

In window a, you will define two functions in your source code. The function names will be: myLoad() and myPreview().

The myLoad() function will be called on the onLoad user event of your document object.

The myLoad() function will set your window a to be the 90% of the available width and 90% of the available height of your monitor screen. This function will also move the page to the 0,0 coordinates on the screen.

In window a, you will define three arrays in your JavaScript code. These arrays must be defined script-level not inside a function.

The first array will hold the names of 5 Web sites. You will use the names of the sites, not the URLS. Please use no fewer than 5 sites and no more than 10. Please do not name the array “links” as this is a reserved array name in JavaScript.

create a second array which will hold a simple description of the web site. This should only be a sentence of two.

create a third array that will hold the URLs of the 5 Web sites.

For each of the arrays, you must initialize each array as an instance of the Array object, but without specifying a number of elements, so that the arrays are dynamic. To load the arrays, use the push() method of the Array object to load the arrays: sitename.push(“site one”); sitename.push(“site two”);

On the window a page (firstwindow.html) you will create 5 links. Each web site name will be a link that stays anchored on the page, but calls a function with the onClick user event. It should look like this <a href = “#” onClick = “myPreview(4)”>. Into your function you will pass the number which represents the position of the array your site name occupies. For example, for the first site in the array, you will pass 0. You can hardcode these links in HTML

The myPreview() funciton will receive the number from the argument to the function and use that to determine which element in your links array to access. The myPreview() function will open up window b. It will define a new window var windowb and will check to see if windowb is open. If windowb is currently open, the myPreview function will first close windowb, then re-open windowb using window.open().

Window “b” details:

The myPreview() function, defined and called in window a, will open, define and create window b.

For window b, the menubar will be set to no, you also must set at 400 pixels wide and 300 pixels tall.

The title of window b will be the same as the site name in your site name array (your first array). Your pop up window will not be a pre-designed page, but rather you will use “” to denote to open up a blank window. You will write all the html into the pop up window, including all of your html tags.

As you are writing the html into the new pop up window, you will also write in the element from your description array that holds the short description of the site and the link to the external site using the third array, which contains the URLS. In the <a href> tag you will create in windowb, you will use target = “_blank” to open up the external site in a new window.

Window “c” details:

This window is a window containing the external site.
———-

a challenge for you hardcore dev peeps out there from a lowly designer…

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@sorciereauthorJul 24.2003 — can no one figure this out..? I sure can't. I've got the myLoad function solved - I just haven't been able to figure out the arrays for the websites -
Copy linkTweet thisAlerts:
@David_HarrisonJul 24.2003 — Why specifically the push method for creating the arrays, why not just use:

var site_names=new Array();

site_names[0]="World Wide Web Consortium";

site_names[1]="Caulolli";

site_names[2]="Postopia";

site_names[3]="SF Cave";

site_names[4]="W3 Schools";

Also if you want help, why not just ask rather than making it a challange?
Copy linkTweet thisAlerts:
@sorciereauthorJul 24.2003 — that does help - thanks. I am asking for help - sorry my wording my be off a bit. I guess I said Challenge cause I've been pouring over this problem for awhile and its become a big challenge for me.
Copy linkTweet thisAlerts:
@David_HarrisonJul 24.2003 — I'll get back to you tomorrow with the answer then because I've got to go offline pretty soon, it's a bit late where I am.
Copy linkTweet thisAlerts:
@sorciereauthorJul 24.2003 — Thats great! Thanks! So I'm not exactly sure what the myPreview function would look like and how it would incorporate with the myLoad. For the myLoad function I have:

<script language = "JavaScript">

<!--

function myLoad() {

window.resizeTo(screen.width * .9, screen.height * .9);

window.moveTo(0, 0);

}

</script>

...

<body onload="myLoad()">

Where would the myPreview functions fall into place?
Copy linkTweet thisAlerts:
@David_HarrisonJul 24.2003 — myPreview may look a little like this:

function myPreview(n){

window.open(site_adds[n],"","")

}

and it would have to interact with the myLoad function.
Copy linkTweet thisAlerts:
@sorciereauthorJul 24.2003 — so first I define the myLoad function and then the myPreview function? Like this:

<script language = "JavaScript">

function myLoad() {

window.resizeTo(screen.width * .9, screen.height * .9);

window.moveTo(0, 0);

}

function myPreview(n){

window.open(site_adds[n],"","")

}


</script>

<body onload="myLoad()">
------------------------------------------


Where would I place the:

var site_names=new Array();

site_names[0]="World Wide Web Consortium";

site_names[1]="Caulolli";

site_names[2]="Postopia";

site_names[3]="SF Cave";

site_names[4]="W3 Schools"

Would that come before the functions?
Copy linkTweet thisAlerts:
@David_HarrisonJul 25.2003 — First of all I'd like to correct myself, I saidand it would have to interact with the myLoad function.[/QUOTE]but I meant:

"and it would[B]n't[/B] have to interact with the myLoad function."

Now then, here's your script that I did earlier today:

[upl-file uuid=db8762b3-c3e3-409d-814e-2bec997cb39c size=2kB]window a.txt[/upl-file]
Copy linkTweet thisAlerts:
@sorciereauthorJul 26.2003 — Thank you!
Copy linkTweet thisAlerts:
@David_HarrisonJul 26.2003 — Happy to help. ?
×

Success!

Help @sorciere spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...