/    Sign up×
Community /Pin to ProfileBookmark

a sample javascript question?help me

Hi Friends,

I just learn javascript.I have a sample here

[url]http://24.112.27.16/page1.html[/url]

the page 2 window open when I click open page 2 in page 1.
and page 3 window open when I click open page 3 in page 2.

now I need a feature.I need the page 3 take place page 1 when I click open page 3 in page 2.and also the page2 close.

Please show me how to do it.Thanks so much.

I confuse to use window.location now.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Beach_BumNov 22.2002 — OK, I am confused -

but if you want to replace a page (have one page replace another in its place) use

self.location.replace("xxxx.htm")
Copy linkTweet thisAlerts:
@TheSpiritNov 22.2002 — [i]Originally posted by mshen [/i]

[B]Hi Friends,



I just learn javascript.I have a sample here



http://24.112.27.16/page1.html



the page 2 window open when I click open page 2 in page 1.

and page 3 window open when I click open page 3 in page 2.



now I need a feature.I need the page 3 take place page 1 when I click open page 3 in page 2.and also the page2 close.



Please show me how to do it.Thanks so much.



I confuse to use window.location now. [/B]
[/QUOTE]


Okay you want:

Page 1:

click "open page 2" to open it in a new window

Page 2:

click "open page 3" to open page 3 in Page 1's window and close Page 2's window.

I am rusty on the use of parent and self, but this MIGHT be how you could do that.

when the user clicks the "open page 3" button on page 2, try using:

parent.location.replace("page3.html") OR parent.location="page3.html"

AND

self.close()
×

Success!

Help @mshen 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...