/    Sign up×
Community /Pin to ProfileBookmark

Javascript loading client pages

Hi,

I have a website with a client area which allows clients to type in a password into a form and upon submit load their specific page. It’s not really a password system – the password is simply the name of the webpage minus the ‘.html’ (security isn’t an issue!). At the moment from the main site a popup window can be opened containing the password form. Once the password is submitted, the popup is automatically closed and the relevant client page is loaded into the parent window of the main site. I’m using the following code to achieve this:

[CODE]function goForit() {
var location;
var password;
password=this.document.testform.inputbox.value
location=password + “.html”
fetch(location)
theKeeper=window.close()
}
function fetch(location) {
var root;
if (opener.closed) {
root=window.open(”,’theKeepersGopher’,’toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no’);
root.location.href = location;
} else {
opener.location.href = location;
}
}[/CODE]

My problem is I want to load the client page into a new browser window rather than the parent window of the main site. I imagine I need to add a ‘target=”blank”‘ somewhere, but my javascript knowledge is poor, so I don’t know where! Any ideas? Help would be greatly appreciated!

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJun 24.2006 — This test controls what happens with the client page:
if (opener.closed) {
root=window.open('', 'theKeepersGopher', 'copyhistory=no,menubar,toolbar,location,status,scrollbars,resizable');
root.location.href = location;
} else {
opener.location.href = location;
}

if you so choose, you can change that to just this:
window.open(location, 'theKeepersGopher', 'copyhistory=no,menubar,toolbar,location,status,scrollbars,resizable');
Copy linkTweet thisAlerts:
@djvernauthorJun 24.2006 — thanks, just what I needed!

If it's possible I also wanted to show a javascript alert if a user types in a password that relates to a page that doesn't exist, rather than just have a 'page not found' window displayed. Is there anyway to add such a function into the existing code I have?
Copy linkTweet thisAlerts:
@phpnoviceJun 24.2006 — If it's possible I also wanted to show a javascript alert if a user types in a password that relates to a page that doesn't exist...[/QUOTE]
That would require either an array to validate the pages against (which destroys part of yoru security) or an Ajax HEAD request to verify the existence of the page at the server. For the Ajax HEAD request, use the advanced search on this forum for user:

[B]phpnovice[/B]

and the following keywords:

[B]ajax head[/B]
Copy linkTweet thisAlerts:
@djvernauthorJun 24.2006 — hm, I think the site doesn't warrant such complex code, so think I 'll just put a little warning message up on the popup window. Thanks for your help again!
Copy linkTweet thisAlerts:
@phpnoviceJun 24.2006 — You're welcome.

Cheers.
×

Success!

Help @djvern 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.9,
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,
)...